任何人都可以解释我为什么会发生这种情况? 我有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文件。 ?您是否以编程方式设置视图的大小? –