我想展开以下TextView,以便它们垂直占据整个屏幕。我想留下按钮,因为它们在那个尺寸的底部。
这是我的XML文件....
<?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"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="9"
android:gravity="center"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="SN : "
android:layout_weight="1" />
<TextView
android:id="@+id/serialNumberView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_weight="2"
android:text=""/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Ver : "
android:layout_weight="1" />
<TextView
android:id="@+id/versionView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_weight="2"
android:text=""
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Type:"
android:layout_gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="@+id/typeView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_weight="2"
android:text="" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow>
<TextView
android:text="V1 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vOneView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="V2 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vTwoView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="V3 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vThreeView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="I1 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/iOneView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="I2 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/iTwoView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="I3 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/iThreeView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="VD1 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vDOneView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="VD2 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vDTwoView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="VD3 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vDThreeView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:text="Temp : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/temperatureId"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<Button
android:id="@+id/celciusFarenheitButton"
android:text="C/F"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView
android:id="@+id/viewInfo"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
</TableLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1" >
<Button
android:id="@+id/backButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Back"
android:layout_weight=".33333333333333" />
<Button
android:id="@+id/readButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Read"
android:layout_weight=".33333333333333333" />
<Button
android:id="@+id/analogsButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Analogs"
android:layout_weight=".333333333333333" />
</LinearLayout>
</LinearLayout>
答案 0 :(得分:5)
我已将您的ScrollView
更改为RelativeLayout
,并在每行中更改了属性
android:layout_height="0dp"
和android:layout_weight="1
“
Xml看起来像这样:
<?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"
android:weightSum="1.0" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="SN : "
android:layout_weight="1" />
<TextView
android:id="@+id/serialNumberView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_weight="2"
android:text=""/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Ver : "
android:layout_weight="1" />
<TextView
android:id="@+id/versionView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_weight="2"
android:text=""
/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Type:"
android:layout_gravity="center"
android:layout_weight="1"
/>
<TextView
android:id="@+id/typeView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center"
android:layout_weight="2"
android:text="" />
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:shrinkColumns="*"
android:stretchColumns="*">
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="V1 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vOneView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="V2 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vTwoView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="V3 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vThreeView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="I1 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/iOneView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="I2 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/iTwoView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="I3 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/iThreeView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="VD1 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vDOneView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="VD2 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vDTwoView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="VD3 : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/vDThreeView"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="Temp : "
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<TextView
android:id="@+id/temperatureId"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
<Button
android:id="@+id/celciusFarenheitButton"
android:text="C/F"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
<TableRow android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:id="@+id/viewInfo"
android:layout_width="fill_parent"
android:gravity="center_horizontal" />
</TableRow>
</TableLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/backButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Back"
android:layout_weight="1" />
<Button
android:id="@+id/readButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Read"
android:layout_weight="1" />
<Button
android:id="@+id/analogsButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="Analogs"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>