Android 使用RelativeLayout使视图占用所有剩余空间
我想做到这一点Android 使用RelativeLayout使视图占用所有剩余空间,android,android-layout,android-relativelayout,Android,Android Layout,Android Relativelayout,我想做到这一点 我正在这样做 <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/upper" android:orientation="horizontal" android:layout_width="fill_p
我正在这样做
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/upper"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/wallet_dim_foreground_inverse_disabled_holo_dark">
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:layout_below="@+id/upper"
android:background="@color/blueAccentColor">
</LinearLayout>
</RelativeLayout>
必须将第一个布局设置在第二个布局之上 使用您提供的代码,您将拥有一个占据所有空间的顶部布局,而底部布局位于其下方。如果你仔细想想,你会发现结果会有所不同,这是合乎逻辑的 如果从下方移除
android:layout\u=“@+id/upper”
并从下方添加android:layout\u alignParentBottom=“true”
,则此布局将锚定到底部,以屏幕大小为准
除了将android:layout\u over=“@+id/lower”
添加到顶部布局之外,他将占据所有空间(感谢android:layout\u height=“fill\u parent”
),但它将保持在较低布局之上
这是您想要的结果:)您必须将第一个布局设置为位于第二个布局之上 使用您提供的代码,您将拥有一个占据所有空间的顶部布局,而底部布局位于其下方。如果你仔细想想,你会发现结果会有所不同,这是合乎逻辑的 如果从下方移除
android:layout\u=“@+id/upper”
并从下方添加android:layout\u alignParentBottom=“true”
,则此布局将锚定到底部,以屏幕大小为准
除了将android:layout\u over=“@+id/lower”
添加到顶部布局之外,他将占据所有空间(感谢android:layout\u height=“fill\u parent”
),但它将保持在较低布局之上
这是您想要的结果:)您必须将第一个布局设置为位于第二个布局之上 使用您提供的代码,您将拥有一个占据所有空间的顶部布局,而底部布局位于其下方。如果你仔细想想,你会发现结果会有所不同,这是合乎逻辑的 如果从下方移除
android:layout\u=“@+id/upper”
并从下方添加android:layout\u alignParentBottom=“true”
,则此布局将锚定到底部,以屏幕大小为准
除了将android:layout\u over=“@+id/lower”
添加到顶部布局之外,他将占据所有空间(感谢android:layout\u height=“fill\u parent”
),但它将保持在较低布局之上
这是您想要的结果:)您必须将第一个布局设置为位于第二个布局之上 使用您提供的代码,您将拥有一个占据所有空间的顶部布局,而底部布局位于其下方。如果你仔细想想,你会发现结果会有所不同,这是合乎逻辑的 如果从下方移除
android:layout\u=“@+id/upper”
并从下方添加android:layout\u alignParentBottom=“true”
,则此布局将锚定到底部,以屏幕大小为准
除了将android:layout\u over=“@+id/lower”
添加到顶部布局之外,他将占据所有空间(感谢android:layout\u height=“fill\u parent”
),但它将保持在较低布局之上
这是您想要的结果:)
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/upper"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/lower"
android:background="@color/wallet_dim_foreground_inverse_disabled_holo_dark">
</LinearLayout>
<LinearLayout
android:id="@+id/lower"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:background="@color/blueAccentColor"></LinearLayout>
</RelativeLayout>