更改Theme.Dialog看起来像Theme.Light.Dialog Android中Dialog、Theme、Android、Light

2023-09-06 02:32:39 作者:人比黄花瘦

没有 Theme.Light.Dialog 与我的项目中正在使用的其余部分使用 Theme.Light

如何修改 Theme.Dialog 看起来像一个 Theme.Light 版本对话。

我知道我必须覆盖styles.xml Theme.Dialog 的部分如下。我应该覆盖与价值观是什么项目?

 <样式名称=dialog_light父=@安卓风格/ Theme.Dialog>
    <项目名称=机器人:???????>< /项目>
    <项目名称=机器人:???????>< /项目>
< /风格>
 

我可以只让背景光白灰色,但按钮,纺织等也都对光线的主题更好看在浅色背景不同。

修改

看起来像我得到它的工作。

 <颜色名称=黑>#FF000000< /彩色>
<颜色名称=whitegrey>#FFF2F2F2< /彩色>

<样式名称=dialog_light父=@安卓风格/ Theme.Dialog>
    <项目名称=@安卓windowBackground> @色/ whitegrey< /项目>
    <项目名称=@机器人:文字颜色> @彩色/黑白LT; /项目>
< /风格>
 
Android的主题Theme遇到的问题 java.lang.IllegalStateException You need to use a Theme.AppCompat theme

解决方案

看起来像我得到它的工作。

 <颜色名称=黑>#FF000000< /彩色>
<颜色名称=whitegrey>#FFF2F2F2< /彩色>

<样式名称=dialog_light父=@安卓风格/ Theme.Dialog>
    <项目名称=@安卓windowBackground> @色/ whitegrey< /项目>
    <项目名称=@机器人:文字颜色> @彩色/黑白LT; /项目>
< /风格>
 

There is no Theme.Light.Dialog to use with the rest of my project that is using Theme.Light.

How can I change Theme.Dialog to look like a Theme.Light version of Dialog.

I know that I must overwrite sections of Theme.Dialog in styles.xml as below. What items should I overwrite with which values?

<style name="dialog_light" parent="@android:style/Theme.Dialog">
    <item name="android:???????"></item>
    <item name="android:???????"></item>
</style>

I could just make the background that light white grey, but the buttons, spinners etc are also different on the light theme to look better on the light background.

EDIT

Looks like I got it working.

<color name="black">#FF000000</color>
<color name="whitegrey">#FFF2F2F2</color>

<style name="dialog_light" parent="@android:style/Theme.Dialog">
    <item name="@android:windowBackground">@color/whitegrey</item>
    <item name="@android:textColor">@color/black</item>        
</style>

解决方案

Looks like I got it working.

<color name="black">#FF000000</color>
<color name="whitegrey">#FFF2F2F2</color>

<style name="dialog_light" parent="@android:style/Theme.Dialog">
    <item name="@android:windowBackground">@color/whitegrey</item>
    <item name="@android:textColor">@color/black</item>        
</style>