简体   繁体   中英

style.xml android:windowIsTranslucent dialogs not showing

I have created a transparent AppCompatActivity that is a type of 'launcher' activity for other activities. This launcher activity uses a transparent style as found with other stackoverflow questions.

<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.Light.NoActionBar">
        <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>
</style>


<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorAccent">@color/primary</item>
</style>

Sometimes this launcher activity needs to show a progress dialog. However, the progress dialog does not show up when I use the tag android:windowIsTranslucent . Commenting out this tag allows the progress dialog to appear, but the activity is no longer transparent.

Is there some sort of alternative solution for this?

I didn't tried this solution, But i think this could work. Just add <item name="android:windowIsTranslucent">false</item> in your AppCompatAlertDialogStyle

Solution would be like

<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.Light.NoActionBar">
        <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>
</style>


<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
        <item name="colorAccent">@color/primary</item>
        <item name="android:windowIsTranslucent">false</item>
</style>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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