0

Android で簡単なテーブル レイアウトを作成したいのですが、いくつか問題がありました。パート 1: テキスト ビューがいくつかあるので、その TableRow の高さを wrap_content に入れたいと思います。パート 2: 同じこと。

それは今でもすべて動作しますが:

パート 3: 2 つのリストビューがあり、パート 4 にはいくつかのボタンがあります。

私はこのようなことをしたいと思います: パーツ 4 の高さでコンテンツをラップしますが、パーツ 3 は画面上のすべての空きスペースを埋めるようにします。

忙しい猫

パート3を調べたときに、画面の下部まですべての空のスペースが埋められたため、これに対する解決策を教えてください。今、私は weight_sum を試してみましたが、4 番目の行を wrap_content にするので、好きではありません。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:weightSum="1.0" >

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:weightSum="1.0" >

    <TextView
        android:id="@+id/phone_tab_text_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:background="@layout/style_right_border"
        android:gravity="center"
        android:singleLine="true"
        android:text="Phone Tab"
        android:textColor="@android:color/white"
        android:textSize="14dp" />

    <TextView
        android:id="@+id/pc_tab_text_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.7"
        android:gravity="center"
        android:singleLine="true"
        android:text="PC Tab"
        android:textColor="@android:color/white"
        android:textSize="14dp" />
</TableRow>

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@layout/style_bottom_border" >

    <TextView
        android:id="@+id/phone_path_text_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:background="@layout/style_bott_right_border"
        android:gravity="center"
        android:paddingBottom="5dp"
        android:singleLine="true"
        android:text="mnt/sdcard/Movies/dpad/sadas/asda/sda/as"
        android:textColor="@android:color/white"
        android:textSize="8dp" />

    <TextView
        android:id="@+id/pc_path_text_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.7"
        android:gravity="center"
        android:paddingBottom="5dp"
        android:singleLine="true"
        android:text="mnt/sdcard/Movies/dpad/sadas/asda/sda/as"
        android:textColor="@android:color/white"
        android:textSize="8dp" />
</TableRow>

<TableRow
    android:id="@+id/tableRow3"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="0.9"
    android:weightSum="1.0" >

    <ListView
        android:id="@+id/listview_phone_files"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:background="@layout/style_right_border" />

    <ListView
        android:id="@+id/listview_pc_files"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.7" />
</TableRow>

<TableRow
    android:id="@+id/tableRow4"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="0.1"
    android:background="@layout/style_top_border"
    android:gravity="center"
    android:weightSum="1.0" >

    <Button
        android:id="@+id/button1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:text="Button" />

    <ImageButton
        android:id="@+id/button_active_tab_changer"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.4"
        android:background="@android:color/transparent"
        android:onClick="changeActiveTabButton"
        android:src="@drawable/button_change_tab" />

    <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:text="Button" />
</TableRow>

4

3 に答える 3

1

このレイアウトを確認してください。ただし、古いレイアウト ファイルはバックアップしておいてください。

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/black"
    android:weightSum="1.0" >

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:weightSum="1.0" >

    <TextView
        android:id="@+id/phone_tab_text_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:gravity="center"
        android:singleLine="true"
        android:text="Phone Tab"
        android:textColor="@android:color/white"
        android:textSize="14dp" />

    <TextView
        android:id="@+id/pc_tab_text_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.7"
        android:gravity="center"
        android:singleLine="true"
        android:text="PC Tab"
        android:textColor="@android:color/white"
        android:textSize="14dp" />
</TableRow>

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/phone_path_text_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:gravity="center"
        android:paddingBottom="5dp"
        android:singleLine="true"
        android:text="mnt/sdcard/Movies/dpad/sadas/asda/sda/as"
        android:textColor="@android:color/white"
        android:textSize="8dp" />

    <TextView
        android:id="@+id/pc_path_text_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.7"
        android:gravity="center"
        android:paddingBottom="5dp"
        android:singleLine="true"
        android:text="mnt/sdcard/Movies/dpad/sadas/asda/sda/as"
        android:textColor="@android:color/white"
        android:textSize="8dp" />
</TableRow>

<TableRow
    android:id="@+id/tableRow3"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="1" >

    <ListView
        android:id="@+id/listview_phone_files"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1" />

    <ListView
        android:id="@+id/listview_pc_files"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1" />
</TableRow>

<TableRow
    android:id="@+id/tableRow4"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="0.1"
    android:gravity="center"
    android:weightSum="1.0" >

    <Button
        android:id="@+id/button1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:text="Button" />

    <ImageButton
        android:id="@+id/button_active_tab_changer"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.4"
        android:background="@android:color/transparent"
        android:onClick="changeActiveTabButton"
        android:src="@android:drawable/ic_delete" />

    <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.3"
        android:text="Button" />
</TableRow>
</TableLayout>
于 2013-05-08T06:43:53.097 に答える