单选按钮不能正确绘制背景 [英] RadioButton not drawing background correctly

查看:170
本文介绍了单选按钮不能正确绘制背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我在我束手无策这一个。我使用的是开源的一块$ C $下分段单选按钮(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.

这是它应该是什么样子:

This is how it should look like:

而这正是它看起来就像在Xperia X10的和宏碁Liquid E:

And this is what it's looking like on the Xperia X10 and Acer Liquid E:

我一直在谷歌搜索的答案,仍然没有运气,所以我想我会来这里,看看是否任何人有任何想法可能是什么导致它。我基本上使用相同的code的布局作为例子,但在这儿的一部分,以供参考:

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>

任何帮助将是很大的AP preciated!

Any help would be greatly appreciated!

推荐答案

我曾与索尼爱立信的设备同样的问题......我用的解决方法是建立在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.

这篇关于单选按钮不能正确绘制背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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