我正在Android中執行TicTacToe。當我點擊ImageButton時,顯示應用程序的圖像會放大組件,而不考慮按鈕的大小。適合ImageButton的圖像
我使用的屬性android:scaleType="fitCenter"
(幾乎fitXY
,centerInside
,fitCenter
,fitStart
)要儘量合身組件內的圖像,但沒有奏效。
這是我的我的ImageButton的XML
代碼的一部分:
<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虛擬設備的遊戲,它發生一樣的問題)。
我會感謝任何幫助解決我的問題。謝謝。
謝謝,夥計。非常有用。 – ArCiGo 2014-10-03 06:43:46
很高興我幫你!並感謝您接受我的回答。 – Programmer 2014-10-03 12:41:55