这是我的代码。工具栏有固定的位置。你如何在它们之间实现拉伸中间布局(网格/列表视图)?
提前致谢。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/toolbar"
android:id="@+id/top_toolbar"/>
<RelativeLayout
android:id="@+id/ll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_alignTop="@+id/top_toolbar">
<GridView
android:id="@+id/gv_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:numColumns="auto_fit" />
<ExpandableListView
android:id="@+id/id_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:visibility="gone"/>
</RelativeLayout>
<include layout="@layout/bottom_toolbar"/>
答案 0 :(得分:1)
我会将第一个RelativeLayout
更改为LinearLayout
并在第二个android:layout_weight="1"
中添加RelativeLayout
,如下所示:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/toolbar"
android:id="@+id/top_toolbar"/>
<RelativeLayout
android:id="@+id/ll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_alignTop="@+id/top_toolbar">
<GridView
android:id="@+id/gv_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:numColumns="auto_fit" />
<ExpandableListView
android:id="@+id/id_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:visibility="gone"/>
</RelativeLayout>
<include layout="@layout/bottom_toolbar"/>