0

我想展开以下 TextViews 以便它们垂直占据整个屏幕。我想把按钮留在那个尺寸的底部。

在此处输入图像描述

这是我的 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>
4

1 回答 1

5

我已将您更改ScrollView为 a RelativeLayout,并且在每一行中的 Attribute 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>

在此处输入图像描述

于 2012-06-25T19:37:27.240 回答