私は Android 用のメモリー ゲームに取り組んでいますが、レイアウトに少し問題があります。
ゲームの種類 (イージー、ミディアム、ハード) ごとに 3 つの異なるレイアウトがあり、一致させる必要がある 4x4、5x5、または 6x6 の画像が画面に表示されます。
ImageAdapter を使用して画像を取得し、画面に画像を表示するために使用している GridView を埋めています。
Easy ゲームの XML ファイル (4x4 画像) は次のとおりです。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/mainBar"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:gravity="center">
<TextView
android:id="@+id/player1"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Player1 - "
/>
<TextView
android:id="@+id/player1Score"
android:layout_toRightOf="@+id/player1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00 "
/>
<TextView
android:id="@+id/player2Score"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00"
/>
<TextView
android:id="@+id/player2"
android:layout_toLeftOf="@+id/player2Score"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Player2 - "
/>
<Chronometer
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="02:00" />
</RelativeLayout>
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true"
android:layout_below="@id/mainBar"
android:gravity="center_vertical|center_horizontal"
android:numColumns="4">
</GridView>
</RelativeLayout>
唯一の問題は、画面サイズが小さいエミュレーターでアプリを実行すると、画像が引き伸ばされて見えることです....(IMG#1を参照)..私が本当にこのように見せたいとき..(サイズに関係なく、すべての画面で IMG#2 を参照してください。
異なるリソースを使用しています (ldpi、mdpi、hdpi の異なるイメージ)。