RadioButton not drawing background correctly(RadioButton 未正确绘制背景)
问题描述
好吧,我对此一无所知.我正在使用分段单选按钮的开源代码(https://github.com/makeramen/android-segmentedradiobutton),它运行良好,除了少数设备无法正确绘制单选按钮.
Alright, I'm at my wits end with this one. I am using an open-source piece of code for segmented radio buttons (https://github.com/makeramen/android-segmentedradiobutton) and it's working great, except for the few devices where it won't draw the radio buttons correctly.
它应该是这样的:
这就是它在 Xperia X10 和 Acer Liquid E 上的样子:
And this is what it's looking like on the Xperia X10 and Acer Liquid E:
我一直在谷歌搜索答案,但仍然没有运气,所以我想我会来这里看看是否有人知道是什么原因造成的.我基本上使用与示例相同的代码,但此处部分布局供参考:
I have been Googling for an answer and still have no luck so I thought I would come here and see if anyone had any idea what could be causing it. I'm basically using the same code as the examples but here part of the layout for reference:
<com.makeramen.segmented.SegmentedRadioGroup android:id="@+id/jfl_calendar_tabselect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:checkedButton="@+id/all_button">
<RadioButton android:id="@id/all_button"
android:minWidth="80dip"
android:minHeight="50dip"
android:text="@string/calendar_all"
android:button="@null"
android:textSize="13dip"
android:gravity="center"
android:textColor="@color/radio_colors" />
<RadioButton android:id="@+id/mine_button"
android:minWidth="80dip"
android:minHeight="50dip"
android:text="@string/calendar_mine"
android:button="@null"
android:textSize="13dip"
android:gravity="center"
android:textColor="@color/radio_colors"
android:padding="3dip" />
<RadioButton android:id="@+id/friends_button"
android:minWidth="80dip"
android:minHeight="50dip"
android:text="@string/calendar_friends"
android:button="@null"
android:textSize="13dip"
android:gravity="center"
android:textColor="@color/radio_colors"
android:padding="3dip" />
</com.makeramen.segmented.SegmentedRadioGroup>
任何帮助将不胜感激!
推荐答案
我在索尼爱立信设备上遇到了同样的问题...我使用的解决方法是在 xml 中设置背景:
I had the same issue with a Sony Ericsson device... the workaround I used was to set the background in the xml:
<RadioButton android:id="@id/button_one"
android:minWidth="40dip"
android:minHeight="33dip"
android:text="One"
android:textAppearance="?android:attr/textAppearanceSmall"
android:button="@null"
android:gravity="center"
android:background="@drawable/segment_radio_left" <-- setting the BG here
android:textColor="@color/radio_colors" />
完成此操作后,背景在首次出现和在按钮之间切换时正确呈现.
After doing this the background rendered correctly when first appearing and when changing between buttons.
因此,如果您的单选按钮是在 xml 中以静态方式定义的,那么在 xml 中设置左、中、右按钮的背景可绘制对象应该可以工作.
So if your radiobuttons are defined in a static way in the xml, setting the background drawable of the left, middle, and right buttons in the xml should work.
这篇关于RadioButton 未正确绘制背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:RadioButton 未正确绘制背景


- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01