0

Androidで次のレイアウトを作成したい。

ここに画像の説明を入力

複数の画面サイズでこの UI を実現するための最適なレイアウトは何ですか? LinearLayout を使用して layout_weight を設定しようとしましたが、2 行目に別の layout_weight が必要になり、パフォーマンスが低下します。TableLayout も使用しようとしましたが、画像サイズが大きいため 3 行目が表示されません。

LinearLayout を使用して、各画面サイズ (mdpi、hdpi など) の画像を作成する必要がありますか?

どんな助けでも大歓迎です。ありがとう。

4

3 に答える 3

0

この方法を試してください。これは、すべての画面を使用したウェイト付きのレイアウト設計作業です。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/ic_launcher" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@drawable/ic_launcher" />

        <ImageView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:src="@drawable/ic_launcher" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:src="@drawable/ic_launcher" />
    </LinearLayout>

</LinearLayout>

出力

ここに画像の説明を入力

于 2013-10-03T11:02:36.777 に答える
0

これがレイアウトの概要です

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView 
    android:id="@+id/image_1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:scaleType="fitXY"
    android:background="@android:color/transparent"
    android:src="@drawable/abox"/>

<LinearLayout 
    android:id="@+id/lin_lt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:weightSum="10"
    android:orientation="horizontal"
    android:layout_below="@+id/image_1">
    <ImageView 
    android:id="@+id/image_2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="5"
    android:scaleType="fitXY"
    android:src="@drawable/abox"
    android:background="@android:color/transparent"/>
    <ImageView 
    android:id="@+id/image_3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="5"
    android:scaleType="fitXY"
    android:src="@drawable/abox"
    android:background="@android:color/transparent"/>
</LinearLayout>
<ImageView 
    android:id="@+id/image_4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/lin_lt"
    android:scaleType="fitXY"
    android:src="@drawable/abox"
    android:background="@android:color/transparent"/>

</RelativeLayout>

画面サイズ/密度グループごとに適切なサイズの画像を提供すると、 LinearLayout を取り除くことができます。また、各画面サイズ/密度に適切なサイズの画像を使用するか、9 パッチ画像を使用することを常にお勧めします。

于 2013-10-03T11:08:43.603 に答える