AndroidでTicTacToeをやっています。ImageButton をクリックすると、ボタンのサイズに関係なく、アプリを表示する画像がコンポーネントを拡大します。
属性android:scaleType="fitCenter"
(almost fitXY
、centerInside
、fitCenter
、fitStart
) を使用して、コンポーネント内に画像を収めようとしましたが、うまくいきませんでした。
これはXML
私の ImageButton の私のコードの一部です:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<ImageButton
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_weight="0.246"
android:onClick="onDonGato"
android:text="" />
<ImageButton
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.246"
android:onClick="onDonGato"
android:scaleType="fitCenter"
android:text="" />
<ImageButton
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.246"
android:onClick="onDonGato"
android:scaleType="fitCenter"
android:text="" />
</LinearLayout>
アプリを実行している Android デバイスは考慮していません (Android 仮想デバイスでゲームを実行したところ、同じ問題が発生したためです)。
私の問題を解決するための助けに感謝します。ありがとう。