RadioButton 未正确绘制背景 [英] RadioButton not drawing background correctly

查看:31
本文介绍了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 未正确绘制背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆