任何人都可以解釋我爲什麼會發生這種情況? 我有3個單選按鈕和3個不同的圖像。對於每個單選按鈕,我創建了一個帶有選擇器的drawable,當單選按鈕被選中時,它不是。它在日食中完美運行,但在模擬器上它可以很好地工作。單選按鈕android
這是圖像。
基於Eclipse:
在仿真器:
下面的代碼:
<RadioGroup
android:id="@+id/radioGroup2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radioButtonSmallBag"
style="@style/radioButtonStyle"
android:checked="true"
android:button="@drawable/small_bag_selector"/>
<RadioButton
android:id="@+id/radioButtonMediumBag"
style="@style/radioButtonStyle"
android:button="@drawable/medium_bag_selector" />
<RadioButton
android:id="@+id/radioButtonBigBag"
style="@style/radioButtonStyle"
android:button="@drawable/big_bag_selector" />
</RadioGroup>
風格:
<style name="radioButtonStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">5dp</item>
<item name="android:layout_marginRight">5dp</item>
</style>
可抽拉:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_checked="true"
android:drawable="@drawable/trip_small_bag_selected"/>
<item
android:state_checked="false"
android:drawable="@drawable/trip_small_bag"/>
</selector>
誰能幫助我?
究竟什麼叫「它不能很好地工作」是什麼意思? –
它不工作,因爲當在模擬器上運行應用程序時,它將單選按鈕的圖像裁減了一半。我上傳了模擬器的圖片 – Short
看來您的佈局已被其他視圖推出,它更小,減肥一些如何。 我想說,你沒有發佈包含radiogroup的整個XML文件。 ?您是否以編程方式設置視圖的大小? –