这是我现在掌握的代码:
<?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" >
<FrameLayout
android:id="@+id/tablet_locations_fragment_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/tablet_locations_fragment_locations_fragment_list_container"
android:layout_width="match_parent"
android:layout_height="90dp" />
</LinearLayout>
我想很明显我希望底部框架布局是90dp高,上部框架布局占据剩余空间,但目前,上部框架布局占据了所有屏幕高度。我该怎么解决?我试着把layout_height=“wrap_content”放在上面的框架布局中,但它并没有改变任何东西。
最佳答案
布局重量是你的朋友
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/tablet_locations_fragment_fragment_container"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp" />
<FrameLayout
android:id="@+id/tablet_locations_fragment_locations_fragment_list_container"
android:layout_width="match_parent"
android:layout_height="90dp" />
</LinearLayout>