gpt4 book ai didi

看不到白色背景的 Android Honeycomb CheckBox

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:07:54 24 4
gpt4 key购买 nike

我将一个 CheckBox 放在白色背景上。它在 Honeycomb 之前的设备上看起来不错,但在 Honeycomb 上,图形似乎有部分透明并且是白色的,所以当复选框未选中时,您看不到它。

我尝试使用 Theme.Holo.Light 样式如下:

<CheckBox android:text="" style="@android:style/Theme.Holo.Light"
android:layout_marginLeft="5dip" android:id="@+id/checkBoxWifiOnly"
android:layout_width="wrap_content" android:layout_height="wrap_content" />

这似乎没有效果。我输入的语法有误吗?

最佳答案

您以错误的方式应用了主题。在 AndroidManifest.xml 中将 @android:style/Theme.Holo.Light 应用于整个应用程序/Activity 。 ,或使用 @android:style/Widget.Holo.Light.CompoundButton.CheckBox 作为 CheckBox 的样式。另请注意,“Holo”主题仅适用于 Honeycomb 及更高版本。

如果您希望复选框具有不同的背景,我认为您必须将主题应用于整个应用程序。问题是,Widget.Holo.Light.CompoundButton.CheckBoxWidget.Holo.CompoundButton.CheckBox 是相同的,并且都扩展了 Widget.CompoundButton。 CheckBox 样式,具有由主题属性 listChoiceIndicatorMultiple 设置的“按钮”变量。该属性的值实际上对于浅色和深色主题是不同的。

我建议您在 values/themes.xml 文件中创建自己的主题,如下所示:

<style name="Theme.MyAwesomeApp" parent="@android:style/Theme.Light">
...
</style>

values-v11/themes.xml 中,像这样:

<style name="Theme.MyAwesomeApp" parent="@android:style/Theme.Holo.Light">
...
</style>

然后在您的 AndroidManifest.xml 中设置它,如下所示:

<application android:theme="@style/Theme.MyAwesomeApp" ... >
...
</application>

也许您还应该阅读主题和样式的工作原理:https://developer.android.com/guide/topics/ui/themes.html

关于看不到白色背景的 Android Honeycomb CheckBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7466501/

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