Java 将 android:Theme.Dialog 更改为 Light AppCompat 对话框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23154387/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change android:Theme.Dialog to Light AppCompat Dialog
提问by PePe
I'm using in my style.xml as main app theme
我在 style.xml 中使用作为主要应用程序主题
<style name="AppTheme" parent="Theme.AppCompat.Light">
And all AlertDialogs using same white/blue colors. But i have Activities which working as Dialog parent="android:Theme.Dialog"
and this box use darktheme. How could I change it to AppCompat.Light
theme?
I tryed Theme.AppCompat.Light.Dialog
but as you know it doesn't working well.
Thanks.
并且所有 AlertDialogs 都使用相同的白色/蓝色。但我有作为对话框工作的活动,parent="android:Theme.Dialog"
这个框使用深色主题。我怎么能把它改成AppCompat.Light
主题?我试过了,Theme.AppCompat.Light.Dialog
但如你所知,效果不佳。谢谢。
采纳答案by Cícero Moura
You can use this theme:
你可以使用这个主题:
<style name="AppTheme" parent="android:Theme.DeviceDefault.Light.Dialog">
Or this:
或这个:
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="MyAppCompatDialogTheme" parent="AppBaseTheme">
<item name="android:windowIsFloating">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowSoftInputMode">stateAlwaysHidden</item>
<item name="android:windowActionModeOverlay">true</item>
<item name="android:windowIsTranslucent">true</item>
</style>