简体   繁体   English

复选框在明暗模式下呈现不同

[英]Checkboxes render differently in light and dark mode

I have a row of checkboxes which seems to get extra spacing in dark mode.我有一排复选框,在暗模式下似乎有额外的间距。 This is the XML for one of the checkboxes:这是复选框之一的 XML:

<CheckBox
    android:id="@+id/cb1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:checked="true" />

This is how the checkboxes look in light mode:这是复选框在浅色模式下的外观:

在此处输入图像描述

And in dark mode:在黑暗模式下:

在此处输入图像描述

The issue exists both in the Android Studio design view and in the physical device: there is extra space around the boxes in dark mode.该问题存在于 Android Studio 设计视图和物理设备中:在暗模式下,框周围有额外的空间。 How do remove this extra space?如何删除这个额外的空间?

by the looks of your code, you didn't use any kind of styling, so i'm amusing you styled all of your CheckBoxs on your app's theme style.从您的代码的外观来看,您没有使用任何样式,所以我很高兴您根据应用程序的主题样式设置了所有 CheckBox 的样式。

if so:如果是这样:

  1. on your [normal] and [-night] style.xml, maybe you used different options for styling CheckBoxs在你的 [normal] 和 [-night] style.xml 上,也许你使用了不同的选项来设置 CheckBox 的样式
  2. on same styling values, maybe you used different parents在相同的样式值上,也许你使用了不同的父母

Try the classic invalidate caches and restart and if the issue still pertains then the problem must be with your grid adding extra padding in dark mode.尝试经典的无效缓存并重新启动,如果问题仍然存在,那么问题一定是您的网格在暗模式下添加了额外的填充。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM