Lor*_*idi 3 android android-layout
我对android视图感到疯狂.我想要一个布局,顶部有一个栏(A),一个栏位于我的应用程序的底部(C)height="wrap_content".中间的完整剩余空间(B)应该是具有另一个布局或其他内容的内容区域TextView.但我不能让这个工作.我尝试了很多布局,但是当我android:layout_height="match_parent"对B 做的时候,C就消失了.有任何想法吗?提前致谢
您可以使用android:layout_weight属性来实现这一点,但您的父容器必须是LinearLayout,在我的示例中,我只使用LinearLayout作为父视图的子项,但您可以使用其他类型的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>
Run Code Online (Sandbox Code Playgroud)
如果你很好奇,想知道它是如何工作的...这里是解释,祝你好运:)