Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android布局独立资源文件夹_Android - Fatal编程技术网

android布局独立资源文件夹

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

假设我在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/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"
/>

此外,您还可以为不同的屏幕大小设置不同的值文件夹,就像布局一样。例如,请参见