android - 单选按钮仅被部分选中

标签 android android-layout android-radiogroup android-radiobutton

我知道这听起来很奇怪所以这是图片。

enter image description here

它拥有正确的值(value)。 (部分)选择了正确的单选按钮。 OnCheckedChangeListener 中的所有逻辑都已正确执行。我完全惊呆了。为什么单选按钮未完全选中?

我唯一能想到的是我正在使用 Rx2Firebase

periodRetriever = FirebaseHelper.getInstance(getContext()).getPeriod()
        .defaultIfEmpty(0)
        .distinctUntilChanged()
        .subscribe(new Consumer<Integer>() {
            @Override
            public void accept(@NonNull Integer headerType) throws Exception {
                getRadioViewChecked(headerType).setChecked(true);
            }
        });

编辑1

Marcos 建议我看不到白色勾号。不是这种情况。 enter image description here

EDIT2

布局:

<RadioGroup
    android:id="@+id/rgPeriod"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <android.support.v7.widget.AppCompatRadioButton
        android:id="@+id/rbMonth"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="false"
        android:text="@string/month" />

    <android.support.v7.widget.AppCompatRadioButton
        android:id="@+id/rbWeek"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="false"
        android:text="@string/week" />

    <android.support.v7.widget.AppCompatRadioButton
        android:id="@+id/rb4Weeks"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:checked="false"
        android:text="@string/four_weeks" />


</RadioGroup>

最佳答案

看起来像一个动画错误。在 ViewPager 内的 Fragment 上使用 CompoundButton 时,可绘制状态设置不正确。

这也发生在复选框中,如下所示:Android Nougat: Why do checkboxes on Fragment have incomplete state when selected programmatically (but look fine on Lollipop) .

在调用 RadioGroup.check(id) 或 Checkbox.setChecked(true) 之后调用 jumpDrawablesToCurrentState() 似乎可以解决问题(thx @Dalmas)

关于android - 单选按钮仅被部分选中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45926301/

相关文章:

Android 选项菜单不显示

android - Play 商店预发布 : limited to devices that support ArCore even though "com.google.ar.core" is set to "optional"

安卓:UI旧界面

android:layout_weight 在 Xamarin 中不起作用

java - 运行 Android KitKat 代码在 Lollipop 设备上崩溃

android - 使用 SAX 解析器或 XmlPullParser 解析 GPX 文件

Android 支持多分辨率和多布局文件夹

Android:为什么单选组中的单选按钮总是为选定的任何项目返回 false?

Android 动态生成的单选按钮一旦以编程方式 setChecked 就不会取消选中

android - 单个单选组中水平和垂直方向的单选按钮