在 activity_main.xml 中,有两行代码android:background="@drawable/border_ui"
和android:background="@drawable/my"
,但是使用 border_ui.xml 的这个位于文件夹 res\drawable,另外一个使用文件 drawable.xml 的位于文件夹 res\values 中。
有什么不同?
还有如果我移除文件 drawable.xml 到文件夹 res\drawable 中,重命名为 my.xml。
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="@drawable/border_ui"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:background="@drawable/my"
/>
</RelativeLayout>
border_ui.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke android:width="1dp" android:color="#000000" />
<solid android:color="#ffffff" />
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
</shape>
drawable.xml
<resources>
<drawable name="my">#f00</drawable>
</resources>