バージョンごとにアプリに加えられた変更の表を表示するアクティビティを作成するように割り当てられました。テーブルには、ID、タイプ、説明、およびバージョンの 4 つの列があります。
これを行うために、TableLayout を scrollView に配置しました。次に、実行時に動的に膨張する TableRows のテンプレートがあります。列幅は固定する必要があります。高さはオーバーフローできますが、幅はオーバーフローしません。
これを実現するために、列コンテナと行コンテナの weight & weight: sum プロパティをそれぞれ使用してみました。layout_width
両方にtoを設定しまし0
た。
問題は、列が画面の境界の外に拡大していることです。画像を投稿しますが、権限がありません。
(ランドスケープは近くに見えますが、外側の境界がまだ切り取られていることがわかります)。
子供たちの体重が合計の約 45% になると、重み付けが正しく見えるようになることに気付きました。
最後に、列を分離するビューには重みが 0 で幅が 1dip 与えられています。(それが問題を引き起こしているかどうかはわかりません)。
私には、重み付けが横長モードであるかのように幅を使用しているように見えます。縦向き用と横向き用の 2 つのレイアウトを作成する必要がありますか?
テーブル行の XML レイアウトを追加しました。
<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/table_row_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<View
android:id="@+id/top_border"
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="#FFFFFF" />
<LinearLayout
android:id="@+id/horizontal_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="4" >
<View
android:id="@+id/view1"
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="#FFFFFF" android:layout_weight="0.01"/>
<TextView
android:id="@+id/txt_id"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Id" android:textSize="10sp" android:layout_weight="0.5"/>
<View
android:id="@+id/view2"
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="#FFFFFF" android:layout_weight="0.01"/>
<TextView
android:id="@+id/txt_type"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Type" android:textSize="10sp" android:layout_weight="1"/>
<View
android:id="@+id/view3"
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="#FFFFFF" android:layout_weight="0.01"/>
<TextView
android:id="@+id/txt_desc"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Description" android:textSize="10sp" android:layout_weight="2"/>
<View
android:id="@+id/view4"
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="#FFFFFF" android:layout_weight="0.01"/>
<TextView
android:id="@+id/txt_version"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Version" android:textSize="10sp" android:layout_weight="0.5"/>
<View
android:id="@+id/view6"
android:layout_width="1dip"
android:layout_height="match_parent"
android:background="#FFFFFF" android:layout_weight="0.01"/>
</LinearLayout>
<View
android:id="@+id/view7"
android:layout_width="match_parent"
android:layout_height="1dip" android:background="#FFFFFF"/>
</LinearLayout>
</TableRow>
上下のビューは上下の境界線です。
そして、これも追加されるテーブルのレイアウトです。
<?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:scrollbarAlwaysDrawVerticalTrack="true">
<ScrollView
android:id="@+id/view_scroll"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:fillViewport="true">
<TableLayout
android:id="@+id/table_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:shrinkColumns="0"
android:stretchColumns="0" >
</TableLayout>
</ScrollView>
</LinearLayout>