0

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?

Nick H
  • 8,897
  • 9
  • 41
  • 64
  • The `ProgressDialog` is most likely using the translucent `Activity`'s theme (depending on how you're initializing it). Try using a [different, non-translucent theme](http://stackoverflow.com/questions/16909958/how-to-set-theme-to-progressdialog) for the `ProgressDialog`. – Mike M. May 06 '16 at 03:46
  • @MikeM. Thanks for the suggestion Mike. It looks like that constructor targets api 22 and above. Do you have any suggestions for API 16+? – Nick H May 06 '16 at 04:01
  • That progress dialog always inherit the property of it's parent activity, so that's why your progress dialog is not showing when u r applying transparent theme. you should independently apply theme to progress dialog . go for this answer . http://stackoverflow.com/questions/21751662/create-a-progressdialog-only-with-the-spinner-in-the-middle – satya prakash May 06 '16 at 04:01
  • Nah, that constructor's always been available: http://developer.android.com/reference/android/app/ProgressDialog.html#ProgressDialog(android.content.Context,%20int) – Mike M. May 06 '16 at 04:04
  • @MikeM. My apologies, I was setting it with an "android:" theme. You are correct. – Nick H May 06 '16 at 04:05
  • @MikeM. I updated my question with a more up-to-date view of my style.xml. Using your suggestion and setting the ProgressDialog constructor to explicitly set the theme to R.style.AppCompatAlertDialogStyle. Unfortunately it is still not working. – Nick H May 06 '16 at 04:24

1 Answers1

0

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>
Anuj Sharma
  • 4,294
  • 2
  • 37
  • 53
  • Thanks for the suggestion, I actually just tried this! and it didn't appear to work. Something else that is noteworthy is when I attempted to show an alert dialog with some buttons it appeared.. so now i'm thoroughly confused about this lol – Nick H May 06 '16 at 04:31