简体   繁体   English

如何在Android 6.0上使用Theme.AppCompat.Light.Dialog?

[英]How to use Theme.AppCompat.Light.Dialog on Android 6.0?

I want to display activity which should look like dialog. 我想显示看起来像对话框的活动。 I'm using theme inherited from Theme.AppCompat.Light.Dialog to achievie that . 我正在使用从Theme.AppCompat.Light.Dialog继承的主题来实现这一目标。 This solution works quite well on Android 4.x and Android 5.x. 此解决方案在Android 4.x和Android 5.x上运行良好。 Unfortunately on Android 6 it doesn't. 不幸的是,在Android 6上它没有。 I see black background instead of nice transparency. 我看到黑色背景而不是漂亮的透明度。

左边是Android 6,右边是Android 5

Theme code: 主题代码:

<style name="AppTheme.Popup" parent="Theme.AppCompat.Light.Dialog">
        <item name="windowNoTitle">true</item>
</style>

Activity code - just extended from AppCompatActivity 活动代码 - 仅从AppCompatActivity扩展而来

I was trying to fix using some another settings: 我试图使用其他设置修复:

    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>

Without any success :( 没有任何成功:(

I think you need to sub theme Theme.AppCompat.Light.Dialog.Alert not Theme.AppCompat.Light.Dialog , so your theme will be like: 我认为你需要子主题Theme.AppCompat.Light.Dialog.Alert而不是Theme.AppCompat.Light.Dialog ,所以你的主题将是:

<style name="AppTheme.Popup" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="windowNoTitle">true</item>
</style> 

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

相关问题 将android:Theme.Dialog更改为Light AppCompat对话框 - Change android:Theme.Dialog to Light AppCompat Dialog 无法使用android:Theme.AppCompat.Light - Cannot use android:Theme.AppCompat.Light 如何在Light Appcompat主题中使用来自黑暗主题的SearchView - How to use SearchView from dark theme in Light Appcompat theme android,如何在使用 Theme.AppCompat.Light.DarkActionBar 的同时使用 MaterialCardView - android, how to use MaterialCardView while using Theme.AppCompat.Light.DarkActionBar 如何修复您需要在 Android 的对话框中使用 Theme.AppCompat 主题 - How to fix You need to use a Theme.AppCompat theme in dialog on Android 将android:Theme.Light更改为Theme.AppCompat.Light.DarkActionBar - change android:Theme.Light to Theme.AppCompat.Light.DarkActionBar AppCompat DayNight 主题不适用于 Android 6.0? - AppCompat DayNight theme not work on Android 6.0? Android Theme.AppCompat.Light with Dark Toolbar(用于浅色文本) - Android Theme.AppCompat.Light with Dark Toolbar (for light text) 自定义AlertDialog样式Theme.AppCompat.Light.Dialog.Alert - Custom AlertDialog style Theme.AppCompat.Light.Dialog.Alert 如何解决Theme.AppCompat.Light错误 - How to resolve Theme.AppCompat.Light error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM