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 未正确绘制背景


基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01