注意事项
1:<include />标签 放在使用layout_weight属性的LinearLayout中时,要使用layout_width、layout_height等属性,否则<include/>与其他view比列分配会不正常!
例子:
下面代码正常显示:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ListView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </ListView> <include android:id="@+id/button_bar_include" android:layout_width="match_parent" android:layout_height="wrap_content" layout="@layout/bottom_button_bar"/> </LinearLayout>
下面代码显示出现问题:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ListView android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </ListView> <include android:id="@+id/button_bar_include" layout="@layout/bottom_button_bar"/> </LinearLayout>