How to use Theme.AppCompat.Light.Dialog on Android 6.0? - android

I want to display activity which should look like dialog. I'm using theme inherited from Theme.AppCompat.Light.Dialog to achievie that . This solution works quite well on Android 4.x and Android 5.x. Unfortunately on Android 6 it doesn't. I see black background instead of nice transparency.
Theme code:
<style name="AppTheme.Popup" parent="Theme.AppCompat.Light.Dialog">
<item name="windowNoTitle">true</item>
</style>
Activity code - just extended from 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:
<style name="AppTheme.Popup" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="windowNoTitle">true</item>
</style>

Related

ScrimBackground from Theme.MaterialComponents is not Working

I'm trying to change the scrimBackground that show up when you opened a dialog. And I know that in the new MaterialComponents-Theme is an attribute for this case (scrimBackground). But it is currently not working for me.
On the material.io website that background is also descriped as the scrimBackground and it looks like that it is customizable from the Theme. Has anyone an idea what I'm doing wrong?
https://material.io/design/components/dialogs.html#theming
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="scrimBackground">#android:color/holo_blue_light</item>
<item name="dialogTheme">#drawable/window_scrim</item>
<item name="android:dialogTheme">#style/DialogTheme</item>
<item name="alertDialogTheme">#style/AlertDialogTheme</item>
<item name="android:alertDialogTheme">#style/AlertDialogTheme</item>
</style>
<style name="DialogTheme" parent="Theme.MaterialComponents.Dialog">
<item name="scrimBackground">#drawable/window_scrim</item>
</style>
<style name="AlertDialogTheme" parent="Theme.MaterialComponents.Dialog.Alert">
<item name="scrimBackground">#drawable/window_scrim</item>
</style>
The Material code does not appear to use this attribute even though it is defined. This issue tracks this problem. In the meantime, you may be able to change this without a Material Theme using the advise in Changing default Android fade/scrim color when calling a Dialog.

Android datepicker dialog title pillarboxed

I'm trying to style the datepicker dialog. So far I managed to change the background and button color. But as you can see in the image below, the title is sort of 'pillar-boxed'.
My datepicker dialog with the dark boxes left and right of the title:
My xml code so far (values/styles.xml)
<style name="PickerDialogTheme_dark" parent="Theme.AppCompat.Dialog">
<item name="android:background">#color/colorBackground_bgreen</item>
<item name="android:buttonBarButtonStyle">#style/ButtonColor</item>
</style>
<style name="ButtonColor">
<item name="android:background">#color/colorBackground_bgreen</item>
</style>
In java it is just a regular datepicker dialog constructor with the theme set to PickerDialogTheme_dark and I'm trying to get this to work on pre Lollipop versions.
So hope you guys know how to get rid of this pillar-boxed title. If possible without using fragments and all in xml would be favourable :)
Fixed it finally after searching some more on the internet!
How my final xml code looks now:
<style name="PickerDialogTheme_dark" parent="Theme.AppCompat.Dialog">
<item name="android:gravity">center</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:alertDialogStyle">#style/DialogBackground_dark</item>
<item name="android:windowMinWidthMajor">#android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">#android:dimen/dialog_min_width_minor</item>
</style>
<style name="DialogBackground_dark">
<item name="android:topDark">#color/colorAccent_bgreen</item>
<item name="android:centerDark">#color/colorAccent_bgreen</item>
<item name="android:bottomDark">#color/colorAccent_bgreen</item>
<item name="android:bottomMedium">#color/colorAccent_bgreen</item>
</style>
This is how it looks like now

Libgdx android app remove fullscreen and show titlebar

Here is a link to a doubt i have regarding my app.Any kind of help to solve this will be appreciated.
https://gamedev.stackexchange.com/q/103610/68334
Alright, after checking through the files, I believe the following configurations will work for your case.
In styles.xml, declares GdxTheme.
<style name="GdxTheme" parent="android:Theme">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowFullscreen">false</item>
</style>
In AndroidManifest.xml, set application theme to android:theme="#style/GdxTheme".
This is all you will need to make the status bar visible.

Can't find source of TYPE_SYSTEM_ALERT

For a project I want to create my own window style. I mean something like this:
<style name="MyFloatingWindow">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:background">#android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowNoTitle">true</item>
</style>
To get some ideas how I can implement my ideas I want to look into the style source of andriod but I can't find it. What is the original style of WindowManager.LayoutParams.TYPE_SYSTEM_ALERT?
Or is it possible to create a new layout style with TYPE_SYSTEM_ALERT as parent? What do I have to write as parent?
<style name="MyOverlay" parent="android:***">
</style>
The TYPE_SYSTEM_ALERT simply means that the windows are always on top of application windows. In multiuser systems shows only on the owning user's window. It has nothing to do with the any style of your window or how the window will look like.
There are a lot of pre-defined styles in styles.xml under frameworks\base\core\res\res\values. For example the AlertDialog.
<style name="AlertDialog">
<item name="fullDark">#android:drawable/popup_full_dark</item>
<item name="topDark">#android:drawable/popup_top_dark</item>
<item name="centerDark">#android:drawable/popup_center_dark</item>
<item name="bottomDark">#android:drawable/popup_bottom_dark</item>
<item name="fullBright">#android:drawable/popup_full_bright</item>
<item name="topBright">#android:drawable/popup_top_bright</item>
<item name="centerBright">#android:drawable/popup_center_bright</item>
<item name="bottomBright">#android:drawable/popup_bottom_bright</item>
<item name="bottomMedium">#android:drawable/popup_bottom_medium</item>
<item name="centerMedium">#android:drawable/popup_center_medium</item>
<item name="progressLayout">#android:layout/progress_dialog</item>
<item name="horizontalProgressLayout">#android:layout/alert_dialog_progress</item>
</style>

Fully transparent ActionBarSherlock by using theme

I am using ActionBarSherlock 4.0.2.
I need a fully transparent action bar (without the neon color bottom divider). Hence, I have the following style:
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="windowActionBarOverlay">true</item>
<item name="icon">#drawable/ic_home</item>
<item name="titleTextStyle">#style/ActionBarCompatTitle</item>
<item name="android:windowFullscreen">true</item>
</style>
By using above code, I will still have the following effect.
In order to disable the background, I put the following code in SherlockFragmentActivity#onCreate. Then the problem gone.
getSupportActionBar().setBackgroundDrawable(null);
However, I would like to see the solution being implemented in styles.xml instead of Java code, as I have many other devices with different screen configuration. I modified the styles.xml to the following, without using the previously mentioned fix in the Java code.
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="windowActionBarOverlay">true</item>
<item name="icon">#drawable/ic_home</item>
<item name="titleTextStyle">#style/ActionBarCompatTitle</item>
<item name="android:windowFullscreen">true</item>
<item name="android:background">#drawable/transparent</item>
<item name="background">#drawable/transparent</item>
</style>
However, the neon divider still visible. It seems that my fix using android:background and background does not work. Am I missing something?
<style name="AppTheme" parent="#style/Theme.Sherlock">
<item name="actionBarStyle">#style/AppTheme.ActionBar</item>
<item name="android:actionBarStyle">#style/AppTheme.ActionBar</item>
</style>
<style name="AppTheme.ActionBar" parent="#style/Widget.Sherlock.ActionBar">
<item name="background">#android:color/transparent</item>
<item name="android:background">#android:color/transparent</item>
</style>

Categories

Resources