0

内部に4つの画像を配置するグリッドレイアウトを作成し、xmlを作成しました:

 <GridLayout
    android:layout_width="match_parent"
    android: layout_height="238dp"
    android:columnCount="1"
    android:useDefaultMargins="true"
    tools:ignore="NewApi" >

    <ImageView ... />
    <ImageView ... />
    <ImageView ... />
    <ImageView ... />
 

  </GridLayout>

したがって、それらは次のように表示されます。

ここに画像の説明を入力

そして、私が実際に欲しいのは次のようなものです:

ここに画像の説明を入力

また、デバイスの解像度が異なるため、dp マージンやパディングを使用したくありません。

では、レスポンシブ デザインを考慮して、これら 2 つの列を集中化するにはどうすればよいでしょうか。

4

1 に答える 1

0

GridLayout を使用する代わりに、次のことをお勧めします。

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:gravity="center_horizontal">

    <ImageView
        android:id="@+id/imgView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />

    <ImageView
        android:id="@+id/imgView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/imgView1"
        android:src="@drawable/ic_launcher" />

    <ImageView
        android:id="@+id/imgView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imgView1"
        android:src="@drawable/ic_launcher" />

    <ImageView
        android:id="@+id/imgView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/imgView2"
        android:layout_toRightOf="@+id/imgView3"
        android:src="@drawable/ic_launcher" />
</RelativeLayout>

于 2013-08-28T10:49:30.553 に答える