Android & XML: denied access to inset xmlns changes

Asked 2 years ago, Updated 2 years ago, 124 views

The current question follows the challenge of Android: aligning the input field with the button width.To match the input fields and buttons to the question, the following solution was provided:

<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetBottom="@android:dimen/button_inset_vertical_material"
    android:insetLeft="@android:dimen/button_inset_horizontal_material"
    android:insetRight="@android:dimen/button_inset_horizontal_material"
    android:insetTop="@android:dimen/button_inset_vertical_material">

    <shape>
        <solid android:color="#ffcccccc"/>
        <corners android:radius="2dip"/>
        <padding
            android:bottom="0dip"
            android:left="0dip"
            android:right="0dip"
            android:top="0dip"/>
    </shape>
</inset>

Unfortunately, according to the error message you received, you are not allowed to redefine <inset xmlns>:

Enter a description of the image here

However, it seems that Litmon's computer, which answered the previous question kindly, did not have this error.
The reason may not be related to the access modifier, or the updated Android SDK may no longer be accessible.

android xml

2022-09-30 18:00

1 Answers

System resources (starting with @android:) or library resources have unreferenced private resources.

The error message you see here is not that you have defined the Inset Drawable, but that you have

  • @android:dimen/button_inset_vertical_material
  • @android:dimen/button_inset_horizontal_material

These two system resources are due to private resources.

Originally, these values may be changed or deleted without notice, so I don't recommend them, but

<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:insetBottom="@*android:dimen/button_inset_vertical_material"
    android:insetLeft="@*android:dimen/button_inset_horizontal_material"
    android:insetRight="@*android:dimen/button_inset_horizontal_material"
    android:insetTop="@*android:dimen/button_inset_vertical_material">

    <shape>
        <solid android:color="#ffcccccc"/>
        <corners android:radius="2dip"/>
        <padding
        android:bottom="0dip"
        android:left="0dip"
        android:right="0dip"
        android:top="0dip"/>
    </shape>
</inset>

You can start a resource reference by changing it to @*.

The best way to do this is to copy only the parts you need from your system resources into your project.


2022-09-30 18:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.