RelativeLayout+include产生的问题
16lz
2021-01-23
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/textview" android:layout_height="wrap_content" android:layout_width="wrap_content"/></LinearLayout><!-- lang: xml --><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/layout_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" android:background="@drawable/splash"> <include android:id="@+id/sv" layout="@layout/subview" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_marginLeft="80dp"/> <include android:id="@+id/sv1" android:layout_height="wrap_content" android:layout_width="wrap_content" layout="@layout/subview" android:layout_below="@id/sv"/>
这里在include的时候需要覆盖 android:layout_height和 android:layout_width属性,否则所有其他关于layout的属性设置都会被忽略掉。
参考:http://stackoverflow.com/questions/2316465/how-to-get-relativelayout-working-with-merge-and-include
更多相关文章
- android : 控件在代码中设置属性-setWidth(int pixels)或setHeig
- Android View measure (五) 支持margin属性,从一个异常说起
- Android Banner属性设置
- Android 用属性动画自定义view的渐变背景
- android 属性动画之 ObjectAnimator
- Android 设置对话框中的确定按钮的 enabled 属性