gpt4 book ai didi

java - 为什么复选框中的框不可见?

转载 作者:行者123 更新时间:2023-12-02 10:19:10 25 4
gpt4 key购买 nike

创建此样式后:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/offer_text_background</item>
<item name="colorPrimaryDark">@color/app_background</item>
<item name="android:checkboxStyle">@style/settingsNotificationCategory</item>
</style>

<style name="settingsNotificationCategory">
<item name="android:textSize">30sp</item>
</style>

我的复选框中的框正在删除:

invisible boxes

没有这种风格:

visible boxes

我需要在 kotlin 中动态创建 chceckbox:

var checkBox = CheckBox(this)
checkBox.text = category
checkBox.setTextColor(resources.getColor(R.color.customText))
checkBox.isChecked = true
notificationCategoryLayout.addView(checkBox)

发生什么事了?

我尝试过:

var checkBox = CheckBox(this, null, R.style.settingsNotificationCategory)
checkBox.text = category
checkBox.setTextColor(resources.getColor(R.color.customText))
checkBox.isChecked = true
notificationCategoryLayout.addView(checkBox)

但效果是一样的...

感谢帮助

最佳答案

您为复选框提供了仅包含 textSize 的样式,因此它将影响复选框的样式,您可以做两件事:

首先以编程方式设置文本大小:

checkBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);

或者将你的风格调整为这样:

<style name="settingsNotificationCategory" parent="Widget.AppCompat.CompoundButton.CheckBox">
<item name="android:textSize">30sp</item>
</style>

继承复选框的基本样式

关于java - 为什么复选框中的框不可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54463223/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com