ViewPager とタブ付きの ActionBar があります。これらのタブの 1 つに ListView があり、その ListView のオプションの 1 つをタップすると、その行の詳細ビューである子 Fragment が追加されます。
その詳細ビューは、その中に LinearLayout を持つ ScrollView です。ScrollView はmatch_parent/match_parent
であり、その中width=match_parent
のLinearLayout はheight=wrap_content
です。電話サイズのエミュレーターでは、詳細ビューは必要に応じて画面を埋めますが、タブレットでは、詳細ビューは画面の幅の一部しかカバーしません... ScrollView の幅と LinearLayout の幅は同じですが、両方とも match_parent です。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootView" style="@style/RootScrollView">
<LinearLayout android:id="@+id/scrollContentView" style="@style/ScrollViewContent">
...
</LinearLayout>
</ScrollView>
スクロール ビューのスタイルは次のとおりです。
<style name="RootScrollView">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
コンテンツ LinearLayout のスタイルは次のとおりです。
<style name="ScrollViewContent">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingLeft">15dp</item>
<item name="android:paddingRight">15dp</item>
<item name="android:orientation">vertical</item>
<item name="android:background">@drawable/image_legal_paper_tile</item>
</style>
コンテンツ ビューには、次のような繰り返しの背景image_legal_paper_tile
があります。
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/legal_paper_tile"
android:gravity="fill_horizontal"
android:tileMode="repeat" />
そのため、画像は水平方向に伸びて繰り返し、背景に黄色のリーガル ペーパー パッドが作成されます。
これは、リストと詳細ビューが電話エミュレーターのように見えるものです。
これは、リストと詳細ビューが実際のタブレットでどのように見えるかです。黄色のリーガル パッド フラグメントは、画面の幅全体を埋める必要がありますが、そうではありません。
編集:
背景のリーガルペーパーの画像は次のとおりです。
幅320pxです。電話エミュレーターの幅は 480px で、画像は画面の幅いっぱいに正しく伸びます。その後、意図したとおりに垂直方向に繰り返されます。ただし、タブレットの画面幅いっぱいに伸ばすわけではありません。
タブレットに表示される幅は、コンテンツに基づいてサイズが変わるため、画像の本来のサイズではありません。フラグメントが最初に読み込まれるとき、幅は 1 つです。次に、フィールドに入力して計算を実行し、コンテンツ ビューの下部にテキストを追加します。そのテキストは既存のコンテンツより幅が広いため、テキストが設定されると、幅の広いコンテンツをサポートするためにフラグメントの幅が増加します。
つまり、いいえ、タブレットの幅は画像のネイティブ サイズではありません。画像は伸びていますが、完全には伸びていません。