作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
创建此样式后:
<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>
我的复选框中的框正在删除:
没有这种风格:
我需要在 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/
我是一名优秀的程序员,十分优秀!