I have a pretty common requirement.
I have an Activity that needs to appear Full-screen on Mobile Devices (Size-Normal), and as a Dialog on Tablet Devices(Size-Large and Size-XLarge).
In both the formats, I have UI-Widgets displayed in the content-view of the Activity such as a Horizontal-ProgressBar, Circular-ProgressBar as a load-indicator etc, which need to follow a consistent Material-Design with Custom-Branded colors etc. I cannot forgo this requirement.
I have defined custom-styles based on default Android Themes and Styles, and use them across the App for all Activities. Following are the custom-themes.
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:colorPrimary" tools:ignore="NewApi">
@color/light_black
</item>
<item name="colorPrimary">@color/light_black</item>
<item name="android:colorAccent" tools:ignore="NewApi">@color/sapphire</item>
<item name="colorAccent">@color/sapphire</item>
<item name="android:colorBackground">@color/primary_background</item>
<item name="android:textColorPrimary">@color/title_color</item>
<item name="android:colorButtonNormal" tools:ignore="NewApi">@color/sapphire</item>
<item name="colorButtonNormal">@color/sapphire</item>
<item name="android:colorForeground" tools:ignore="NewApi">
@color/title_color
</item>
<item name="android:titleTextStyle">@style/toolbar_title</item>
<item name="android:navigationIcon" tools:ignore="NewApi">?android:attr/homeAsUpIndicator</item>
<item name="navigationIcon">?android:attr/homeAsUpIndicator</item>
<item name="android:colorControlNormal" tools:ignore="NewApi">@color/white</item>
<item name="colorControlNormal">@color/white</item>
</style>
<style name="AppTheme.Light" parent="AppTheme">
<item name="android:windowBackground">@color/white</item>
</style>
<style name="AppTheme.Dialog" parent="AppTheme.Light">
<item name="android:windowBackgroundFallback" tools:ignore="NewApi">
@android:color/transparent</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundFloating" tools:ignore="NewApi">
@android:color/transparent</item>
<item name="windowActionBar">false</item>
<item name="windowActionBarOverlay">false</item>
<item name="windowActionModeOverlay">false</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowClipToOutline" tools:ignore="NewApi">false</item>
<item name="android:windowTitleStyle">@null</item>
<item name="android:windowTitleBackgroundStyle">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
<item name="android:windowEnableSplitTouch">true</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:fillViewport">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.2</item>
</style>
I use the AppTheme as the default theme across all Activities in the App, and AppTheme.Dialog for the specific Activity described above only for Tablet Devices. The Activity does appear as a Floating-Dialog window centered in the Tablet Screen, dismisses when touched outside like a typical Dialog, everything is good, but the problem is that the Activity's window-background is like pitch-ink-black.
My requirement is that the Activity as a Floating-Dialog in Tablet Devices should have a Transparent Background showcasing the previous activity window-content possibly dimmed and darkened.
How do I achieve this, without having to use Theme.Dialog or Theme.Translucent, as I said before, I need the Material-Design specs for the UI-Widgets not to change from the original "AppTheme" style.
I also will need to re-use a lot of custom private methods declared in the Activity class, so loading the content-view layout-file into a Dialog instance is most definitely not preferred.
Oh, btw, compileSdkVersion is latest at 24, minSdkVersion is 16 and targetSdkVersion is 24, buildToolsVersion is also latest at 24.0.1, but that's a different concern altogether.