Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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 布局\未从包含的ImageView继承边距_Android_Xml_Android Layout - Fatal编程技术网

Android 布局\未从包含的ImageView继承边距

Android 布局\未从包含的ImageView继承边距,android,xml,android-layout,Android,Xml,Android Layout,所以我有两个文件: where_include_happens.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/hours" android:layout_height="wrap_content" android:layout_wi

所以我有两个文件:

where_include_happens.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/hours"
    android:layout_height="wrap_content"
    android:layout_width="60dp">

    <include android:id="@+id/some_id" 
        layout="@layout/whats_included"
        android:layout_width="18dp"
        android:layout_height="18dp" />

</RelativeLayout>
where_include_accounts.xml

whats\u include.xml
我的问题是,这些元素中的每一个都应该有
android:layout\u margin=“6dp”
参数,但它似乎被include忽略了:(。我发现唯一相关的是:

注意:如果要使用标记覆盖布局属性,必须同时覆盖android:layout_高度和android:layout_宽度,才能使其他布局属性生效

我的问题是:


是否有我看不到的东西,或者我注定要写
android:layout\u margin=“6dp”
在我的项目中的每一个include中?

因为你的include.xml由一个ImageView组成,所以只有你可以,而不是使用include指令,为你的ImageView定义一个样式,并根据需要应用该样式。

哇!太棒了!我是android新手,我不知道API中甚至存在这种机制同时也解决了我的许多其他问题,谢谢!+1
whats_included.xml

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_margin="6dp"
    android:contentDescription="@string/some_description"
    android:src="@drawable/some_awesome_drawable"  />