修复LineviewLayout顶部的textview和按钮

时间:2015-07-01 05:05:27

标签: android android-linearlayout

在linearLayout中,我想修复lineViewLayout底部的textView和布局的其余部分,以填充空白区域(中间布局)。对于textView,layout_weight = 0,虚拟textView的按钮和虚拟layout_weight = 1,我希望dummyView将占用布局中的中间布局(由于更多的权重)。但我得到的只是第一个显示的textView。有什么指针吗?

<?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="horizontal" >

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:layout_gravity="center"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:text="@string/text"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/dummy_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:layout_gravity="center"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:textColor="@color/white" />

<Button
    android:id="@+id/complete_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:layout_gravity="center_vertical"
    android:text="@string/done_button"
    android:textAllCaps="true" />

</LinearLayout>

4 个答案:

答案 0 :(得分:3)

使用>>> ['lower' if x < 3 else 'higher' for x in lst] ['lower', 'lower', 'higher', 'higher'] RelativeLayout添加到第一个textView 将alignparentTop添加到按钮

答案 1 :(得分:0)

使用RelativeLayout代替LinearLayout

答案 2 :(得分:0)

将布局从horizontal更改为vertical

<?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**" >

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:layout_gravity="center"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:text="@string/text"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/dummy_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:layout_gravity="center"
    android:layout_marginBottom="20dp"
    android:layout_marginTop="20dp"
    android:gravity="center"
    android:textColor="@color/white" />

<Button
    android:id="@+id/complete_button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:layout_gravity="center_vertical"
    android:text="@string/done_button"
    android:textAllCaps="true" />

</LinearLayout>

答案 3 :(得分:0)

使用android:gravity =&#34; top&#34;对于textView 和android:gravity =&#34; bottom&#34;按钮

相关问题