顶部,底部和顶部的布局剩余空间内容视图 [英] layout with top bar, bottom bar & remaining space content view
问题描述
我对android的观点感到疯狂.我想要使用height="wrap_content"
在我的应用程序的顶部(A)上有一个条形而在(C)底部有一个条形的布局.中间(B)的全部剩余空间应该是带有另一个Layout或TextView
或其他内容的内容区域.但是我无法使它正常工作.我对布局做了很多尝试,但是当我对B做android:layout_height="match_parent"
时,C消失了.有任何想法吗?在此先感谢
I'm getting crazy with the android views. I want a layout with a bar on top (A) and one bar one the bottom (C) of my app with height="wrap_content"
. The full remaining space in the middle (B) should be the content area with another Layout or TextView
or whatever. But i can't get this to work. I tried a lot with the layouts, but when i do android:layout_height="match_parent"
to B, C disappears. Any ideas? Thanks in advance
推荐答案
您可以使用android:layout_weight属性来实现这一点,但是您的父容器必须是 LinearLayout ,在我的示例中,我是m仅使用LinearLayout作为父视图的子视图,但是您可以使用另一种视图:
You can use android:layout_weight property to achieve that, but your parent container has to be a LinearLayout, in my example I'm using just LinearLayout as children of the parent view but you can use another type of View:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layout_a"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
<LinearLayout
android:id="@+id/layout_b"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</LinearLayout>
<LinearLayout
android:id="@+id/layout_c"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</LinearLayout>
If you're curious and wanna know how it works... here is the explanation, good luck :)
这篇关于顶部,底部和顶部的布局剩余空间内容视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!