Android 用のカード ゲームを作成しようとしていますが、レイアウトの問題が発生しています。左右に縦に並んだ 5 枚のカードと、上下に横に並んだ 5 枚のカードで構成されるメインのゲーム画面をコーディングしています。私が抱えている問題は、他のすべてのカードを表示する余地がない場合、すべてのカードを水平方向および垂直方向に縮小する必要があることです。
以下は問題の写真です (わかりやすくするために、左と下のカードは省略しています)。ご覧のとおり、右側には 4 枚のカードしか表示されていません。下のカードは部分的に隠れています。ビューは単にスペースを使い果たしたので、収まらないカードの残りを削除します。
画像を投稿できないため、スクリーンショットへのリンクを次に示します。
この状況で私が望むのは、一番下のカードが完全に見えるようになるまで、Android がすべての一番上のカードと右のカードの高さを減らすことです。複雑ではないようですが、機能させることができません。RelativeLayout を使用して下の画像を作成し、すべての一番上のカードを隣り合わせに配置し、すべての右側のカードを互いに下に配置しました (一番上のカードが一番上のカードのすぐ下にあります)。すべてのカードを独自のビューに追加しようとしましたが、それもうまくいきませんでした。
助言がありますか?ありがとう!
OK、私はそれを近づけました(下部の画像リンクを参照)が、今は反対の問題があります-私はそれを増やす必要があります. スーツに使用している画像を縮小したためだと思います。ご覧のとおり、それらはすべて小さなサイズに縮小されています。LinearLayout の表示部分から最後のボタンを描画せずに、各ボタン セットの LinearLayout を水平方向/垂直方向に拡張してすべての空き領域を使用できるようにしたいと考えています。理想的には、スーツの任意のサイズの画像をドロップして、それを適切にサイズ変更できるようにすることができますが、レイアウト エンジンでいくつかの循環ロジックまたは何かを求めているのではないかと心配しています。
これが私のXMLファイルです。HandView クラスは、各セットの 5 枚のカードを保持するものです。5 枚のカードの間には 5 ピクセルの余白があります。
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:shrinkColumns="*"
android:background="#FF00FF00">
<TableRow
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#FF0000FF">
<com.herscher.euchre.ui.HandView
android:background="#FFFF0000"
android:layout_column="1"
android:orientation="horizontal"
android:id="@+id/northHandView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<com.herscher.euchre.ui.HandView
android:layout_column="0"
android:orientation="vertical"
android:id="@+id/westHandView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.herscher.euchre.ui.PlayArea
android:layout_column="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/playArea" />
<com.herscher.euchre.ui.HandView
android:layout_column="2"
android:orientation="vertical"
android:id="@+id/eastHandView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<com.herscher.euchre.ui.HandView
android:layout_column="1"
android:orientation="horizontal"
android:id="@+id/southHandView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
誰か提案はありますか?