如何让内容填满整个屏幕?
答
如果你使用的RelativeLayout您可以将容器改变的LinearLayout和layout_weight设置为它的孩子们:
<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="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Text 1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:text="Text 2"/>
</LinearLayout>
答
让我们考虑你的XML文件
创建内部RelativeLayout并将其宽度和高度设置为match_parent
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp" >
<!-- here you create your RelativeLayout -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<EditText
android:id="@+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/reminder" />
<TextView
android:id="@+id/dates"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/times" />
<TextView
android:id="@id/times"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/name"
android:layout_alignParentRight="true" />
<Button
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_below="@id/times"
android:layout_centerInParent="true"
android:text="@string/done" />
<!-- here close of your created RelativeLayout -->
</RelativeLayout>
</RelativeLayout>
这是什么,listview还是什么? – 2014-10-19 12:45:42
这是相对的布局,有3个textview和6个按钮 – Soiks 2014-10-19 12:49:16
把所有这个视图放在一个Realative Layout中,并使其高度,宽度如下android:layout_width =“fill_parent”android:layout_height =“fill_parent” – 2014-10-19 12:56:11