我正在为我的第一个 Android 应用程序设计一个相当基本的屏幕布局,并遇到了一些问题。我的目标是在左上角和右上角有一个 TextView,在屏幕正中间有一个大的“hello world”TextView,然后在屏幕底部有一个按钮。我的问题是,要垂直居中“hello world”TextView,我需要设置 layout_height="fill_parent"。但是,这会导致中间的 TextView 覆盖并隐藏屏幕底部的按钮。有没有比我目前正在尝试的更好的方法来做到这一点?我在下面附上了我的 ui xml。谢谢!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow>
<TextView
android:text="@string/label_left" />
<TextView
android:text="@string/label_right"
android:gravity="right" />
</TableRow>
</TableLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello_world"
android:gravity="center"
android:textSize="40sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next_activity"
android:gravity="center"
android:textSize="30sp" />
</LinearLayout>