【发布时间】:2011-10-09 12:27:56
【问题描述】:
我想生成如下所示的 Android 屏幕布局:
Label Text Field
Label Text Field
Label Text Field
-----Button-------
-----TextField----
也就是说,我想在顶部有一个 TableLayout,在表格布局下方有一些项目(主要是为了让这些项目位于屏幕底部)。我尝试将它们嵌套在下面的代码中,但底部的项目似乎没有出现。
有什么想法吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:stretchColumns="1"
android:shrinkColumns="1" android:layout_height="wrap_content" android:layout_gravity="center_vertical">
<TableRow>
<TextView android:text="Latitude:"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
<TextView android:id="@+id/latitude"
android:text="Not available"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
</TableRow>
<TableRow>
<TextView android:text="Longitude:"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView android:id="@+id/longitude"
android:text="Not available"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</TableRow>
<TableRow>
<TextView android:text="Altitude:"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView android:id="@+id/altitude"
android:text="Not available"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</TableRow>
<TableRow>
<TextView android:text="Accuracy:"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<TextView android:id="@+id/accuracy"
android:text="Not available"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</TableRow>
</TableLayout>
<Button android:id="@+id/save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Save"/>
<TextView android:text="Test"/>
</LinearLayout>
【问题讨论】:
标签: android android-layout android-linearlayout tablelayout