android布局独立资源文件夹
假设我在res/layout中有一个文件android布局独立资源文件夹,android,Android,假设我在res/layout中有一个文件 <com.dog.cat.SomeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:ignore="Overdraw" android:id="@+id/Some
<com.dog.cat.SomeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="Overdraw"
android:id="@+id/SomeView"
style="@style/SomeStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
我想在res/layout-sw600dp中有一个类似的布局
<com.dog.cat.SomeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="Overdraw"
android:id="@+id/SomeView"
style="@style/SomeStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding_left="10dp"
/>
我只在第二个文件中添加了android:padding_left=“10dp”。有没有办法将第一个文件添加到第二个文件中,而不必像这样重新键入所有其他属性
<com.dog.cat.SomeLayout
//include all attributes in one line
android:padding_left="10dp"
/>
您可以创建另一种样式,例如:
<style name="SomeStyle.SixHundredDP">
//Put other attributes here
<item name="android:paddingLeft">10dp</item>
</style>
//在此处放置其他属性
10dp
现在,对于res/layout-sw600dp中的布局:
<com.dog.cat.SomeLayout
//Other attributes for this view
style="@style/SomeStyle.SixHundredDP"
/>
此外,您还可以为不同的屏幕大小设置不同的值文件夹,就像布局一样。例如,请参见