android-layout - 使用 "merge"和 "include"

标签 android-layout android

我试图将版权图片放在我的 LinearLayout 的底部,并带有“include 标签”。我做得很成功,但是当我尝试将 android:layout_marginTop="330dp"android:layout_marginBottom="20dp" 添加到我的 include 时 - 它不显示在用户界面中。 有什么问题?

这是我的代码: 版权.xml:

 <merge xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageView
            android:src="@drawable/copyrights"
            android:id="@+id/copyrights"
            android:layout_width="fill_parent"
            android:layout_height="40dip"/>
</merge>

我的布局.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:padding="10dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">  
        <include layout="@layout/copyrights"  android:layout_marginTop="330dp"/>
    </LinearLayout>  

最佳答案

<include />标签基本上是 android 布局框架的复制和粘贴指令。它不是布局层次结构中的实际对象。这意味着它不能有边距/填充/大小/任何其他布局属性。

将边距分配给 <ImageView />在您的布局中。

关于android-layout - 使用 "merge"和 "include",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8156010/

相关文章:

java - 这个怎么修??总是要求更改构造函数 --> mAdapter = new TabsPagerAdapter(getFragmentManager());

Android 在没有空格的 webview 上添加 HTML 内容

android - 使用 Fragment 时相机预览不会填满整个屏幕

安卓 : Decreasing size of the Button

java - Android 的字符串哈希与 serverisde 的不匹配

android - 如何创建从一侧稍微弯曲的矩形背景

android - Android 中的 IPC 使用 GreenRobot 事件总线

android - 为什么在更改设备时不显示操作设置?

java - 在抽屉导航中禁用暗淡化

android - 在 layout.xml 中使用 '@string/value' 时找不到资源