RadioButton 未正确绘制背景

RadioButton not drawing background correctly(RadioButton 未正确绘制背景)
本文介绍了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 未正确绘制背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)