2011-10-24 9 views
0

Hy!私が持っていると思いますディスプレイ4中段の画像

は、このようなレイアウトを持っている:

enter image description here

問題は、私が使用するかわからないです。

  • GridViewの?
  • TableLayout?
  • LinearLayout with PictureViews?

写真が画面の中央に配向されなければならない(horicontal & vertikal)

あなたの答えにいくつかのコード例を追加してください。

THX

答えて

1

私はここからこの画像のダウンロードを使用したレイアウト

<?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:gravity="center_horizontal|center_vertical"> 
    <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> 
     <ImageView android:layout_width="150dp" android:layout_height="150dp" 
      android:layout_weight="1" android:background="@drawable/bg_img" 
      android:layout_margin="5dp"/> 
     <ImageView android:layout_width="150dp" android:layout_height="150dp" 
      android:layout_weight="1" android:background="@drawable/bg_img" 
      android:layout_margin="5dp"/> 
    </LinearLayout> 
    <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> 
     <ImageView android:layout_width="150dp" android:layout_height="150dp" 
      android:layout_weight="1" android:background="@drawable/bg_img" 
      android:layout_margin="5dp"/> 
     <ImageView android:layout_width="150dp" android:layout_height="150dp" 
      android:layout_weight="1" android:background="@drawable/bg_img" 
      android:layout_margin="5dp"/> 
    </LinearLayout> 
</LinearLayout> 

のこのタイプを行うことができます一つの方法は、画像が大きすぎますが、これだったテストでは、唯一のあなただけの背景を置き換えるあなたのイメージを使用することができますあなたの要件ごとに、それぞれのimageviewのsrc。

enter image description here

、あなたはImageview..MainトリックでのLinearLayoutの下に使用してください。この方法のように

enter image description here

0

を結果を得るのLinearLayoutに

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> 
     <ImageView android:id="@+id/imageView1" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent" android:background="@drawable/icon"></ImageView> 
     <ImageView android:id="@+id/imageView2" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/icon"></ImageView> 
    </LinearLayout> 
    <LinearLayout android:id="@+id/linearLayout2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> 
     <ImageView android:id="@+id/imageView3" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent" android:background="@drawable/icon"></ImageView> 
     <ImageView android:id="@+id/imageView4" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent" android:background="@drawable/icon"></ImageView> 
    </LinearLayout> 
</LinearLayout> 
ホット使用重量であります