私は4つのテーブル行の重みを1に設定しました。これは異なる画面サイズで非常にうまく動作します。それは自動的に縮小し、すべての画像を表示し、画面に合うでしょう。androidどのようにtablayoutの画面サイズに応じて画像ビューを自動縮小する?
しかし、私はTablayoutフラグメント内に配置する場合、コンテンツがすべて表示されません。あなたがスクリーンショットから見ることができるように。誰もが問題を知っていますか?どうも。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="com.example.template_tab.frag_two"
android:orientation="vertical">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/img0"
android:src="@drawable/sample_0"
android:layout_weight="1" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/img1"
android:src="@drawable/sample_1"
android:layout_weight="1" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/img2"
android:src="@drawable/sample_2"
android:layout_weight="1" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/img3"
android:src="@drawable/sample_3"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/img4"
android:src="@drawable/sample_4"
android:layout_weight="1" />
<ImageView
android:layout_width="9dp"
android:layout_height="wrap_content"
android:id="@+id/img5"
android:src="@drawable/sample_5"
android:layout_weight="1" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/img6"
android:src="@drawable/sample_6"
android:layout_weight="1" />
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/img7"
android:src="@drawable/sample_7"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:layout_width="9dp"
android:layout_height="wrap_content"
android:id="@+id/img8"
android:src="@drawable/sample_8"
android:layout_weight="1" />
<ImageView
android:layout_width="9dp"
android:layout_height="wrap_content"
android:id="@+id/img9"
android:src="@drawable/sample_9"
android:layout_weight="1" />
<ImageView
android:layout_width="9dp"
android:layout_height="wrap_content"
android:id="@+id/img10"
android:src="@drawable/sample_10"
android:layout_weight="1" />
<ImageView
android:layout_width="9dp"
android:layout_height="wrap_content"
android:id="@+id/img11"
android:src="@drawable/sample_11"
android:layout_weight="1" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/result"
android:src="@drawable/sample_0"
android:layout_weight="1" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/display_text"
android:text="1908, 1920, 1932, 1944, 1956, 1968, 1980, 1992, 2004, 2016, 2028, 2040, 2052, 2064"
android:layout_weight="1" />
</TableRow>
</LinearLayout>
ポストレイアウト・ファイル – Sharj
へ
セット親ビューを追加しました。 plzはあなたもそれは同じように高さ – gosulove
顔をしていますそれでも動作しません。効果は同じです.. – Sharj