1

私は現在、Android向けのゲームに取り組んでいます。

3 つの ImageView が隣り合っており、「android:layout_toRightOf」を使用して隣り合わせに配置されています。ビューは RelativeLayout タグ内にあります。これらの各ビューは、「android:scaleType="fitCenter"」を使用して画面の中央に配置され、画面全体に表示されます。

あるビューから別のビューへの水平スクロールを実装して、基本的に一度に画面に 1 つのビューを表示しようとしています。

ここに私が現在使用しているコードがあります

<HorizontalScrollView android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:fillViewport="true"
      android:scrollbars="none">
  <RelativeLayout android:id="@+id/GameBg"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
     <ImageView  android:id="@+id/GameImageContainer3"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scaleType="fitCenter"
      android:layout_toRightOf="@+id/GameImageContainer2"
      />
     <ImageView  android:id="@+id/GameImageContainer2"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scaleType="fitCenter"
      android:layout_toRightOf="@+id/GameImageContainer1"
      /> 
     <ImageView  android:id="@+id/GameImageContainer1"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:scaleType="fitCenter"
      />
  </RelativeLayout>
</HorizontalScrollView>

私が現在取得しているのは、隣り合った3つの画像ですが、画面全体よりも少ない場合があります。一度に 1 つの画像しか表示できないように、左右の両方のパディングを正しくする必要があります。

何か案は?

4

2 に答える 2

0

ギャラリー ウィジェットを試しましたか。それはあなたが探しているもののようです。ギャラリーのチュートリアルもぜひご覧ください。

于 2010-10-03T18:14:49.750 に答える
0

ViewFlipper を使ってみる

http://www.androidpeople.com/android-viewflipper-example/

于 2011-02-02T14:19:13.020 に答える