单选按钮只是部分检查
我知道这听起来很奇怪,所以这里是图片。单选按钮只是部分检查
它持有正确的值。正确的单选按钮(部分)被选中。 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);
}
});
EDIT1
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>
你的主题是黑暗的,你不能看到白色的刻度,则需要将其更改为另一种颜色。
Obs:我在8月28日评论过这个 –
如果那是真的,改变我活动的背景颜色会揭示这个权利?但是,我的脑海里又出现了一个新的问题,为什么它有时是白色的,有时不是? –
它取决于您正在测试的设备,是的,chaning背景会使其显示 –
试着改变你的主题或您的单选按钮的颜色属性
我不能看到Rx2Firebase
所以你可以尝试使用自定义主题为你的单选按钮的任何问题?从白色到另一种颜色
<style name="MyRadioButton" parent="Theme.AppCompat.Light">
<item name="colorControlNormal">@color/indigo</item>
<item name="colorControlActivated">@color/pink</item>
</style>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="4 weeks"
android:theme="@style/MyRadioButton"/>
更改背景颜色就会出现
您是如何错过该红色图片的? –
对不起罗宾迪克霍夫先生 –
我认为他正在应用一些主题 –
您是否尝试过使用RadioButton
代替android.support.v7.widget.AppCompatRadioButton
我认为这可能会解决这个问题
在另一方面,在这里你可以找到一个如何样式RadioButtons文档
http://www.materialdoc.com/radio-button/
- 在styles.xml文件中声明自定义样式。
<style name="MyRadioButton" parent="Theme.AppCompat.Light"> <item name="colorControlNormal">@color/indigo</item> <item name="colorControlActivated">@color/pink</item> </style>
- 通过安卓应用这种风格到您的单选按钮:主题属性。
`
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Radio Button"
android:theme="@style/MyRadioButton"/>
看起来像一个动画错误。在ViewPager中的Fragment上使用CompoundButton时,drawable状态设置不正确。
这种情况也适用于复选框,如下所示:Android Nougat: Why do checkboxes on Fragment have incomplete state when selected programmatically (but look fine on Lollipop)。
调用jumpDrawablesToCurrentState()只调用RadioGroup.check(ID)或Checkbox.setChecked(真)似乎解决这个问题(感谢@Dalmas)
毕竟这些答案终于有意义的东西。 –
这发生在Nexus 5x API 27上。该片段位于具有片段适配器的活动中。 #jumpDrawablesToCurrentState修复了它 – Reinherd
你指的是一个事实,即圆不具有后点在中心?如果是这样,你的主题是什么,你做了什么来定制'RadioButton'的外观? – CommonsWare
@CommonsWare是的,这就是我指的!除了设置'colorPrimary'和'colorAccent'之外,我没有做过任何样式的设计。当它全部同步时,我没有这个问题。 –
也许你延伸的主题使用白色选择点 如果你使用黑色主题切换到光照或否则 –