I removed the black background of the dialog popup, but now it doesn't close after clicking around the dialog. Backbutton works fine, I'm guessing that an item is missing from the custom theme.
Here is the custom theme I am using.
<style name="customDialogTheme">
<item name="android:windowFrame">#null</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowTitleStyle">#null</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">#android:color/white</item>
</style>
NOTE: Even if i re-enable the black background by setting the <item name="android:backgroundDimEnabled">false</item> to true, it still doesn't click away. I'm pretty sure that I am missing a parameter.
Edit: Only change I made in the java code is:
setStyle(DialogFragment.STYLE_NORMAL, R.style.customDialogTheme);
Seems like I just needed to add parent="Theme.AppCompat.Dialog" to the style.
EDIT: The missing parameter was <item name="android:windowCloseOnTouchOutside">true</item>
Related
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
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.
Edit:
Answer found Here
Why the background of ProgressDialog doesn't set to the transparent?
I know this question has many duplicates, but i can't seem to find a solution.
I want to make my Dialog Background transparent, But it seems not to be working.
This is my code in xml.
<style name="TransparentProgressDialog" >
<item name="android:windowFrame">#null</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowTitleStyle">#null</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">#android:color/transparent</item>
</style>
And this is the output.
Issues 1: It shows a grey background and Shadow around it.
I want only the animation dialog to show.
I've tried using a transparent background image, but still shows the same grey background.
I've also tried using
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
in my Java code but didn't work still.
I recently migrated my app to Material Design and I stumbled upon this problem with my Alert Dialogs:
I'm applying the dialog style like this:
<item name="android:alertDialogTheme">#style/Theme.AlertDialog</item>
and Theme.AlertDialog looks like this:
<style name="Theme.AlertDialog" parent="Base.V14.Theme.AppCompat.Dialog">
<item name="colorPrimary">#color/theme_primary</item>
<item name="colorPrimaryDark">#color/theme_primary_dark</item>
<item name="colorAccent">#color/theme_accent_dark</item>
</style>
This is happening on my Kitkat device and it works fine on Lollipop. Can you help me with getting rid of that outer background?
The point is here:
<style name="Theme.AlertDialog" parent="Base.V14.Theme.AppCompat.Dialog">
...
<item name="colorPrimary">#color/theme_primary</item>
<item name="colorPrimaryDark">#color/theme_primary_dark</item>
<item name="colorAccent">#color/theme_accent_dark</item>
...
<item name="android:windowBackground">#android:color/transparent</item>
...
</style>
As ironman told me here, be sure that you import the right class.
Right : import android.support.v7.app.AlertDialog;
Wrong : import android.app.AlertDialog;
Use the theme in parent
AlertDialog.THEME_DEVICE_DEFAULT_LIGHT
Add below styles . You have to customise background also.
<item name="android:windowFrame">#null</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowTitleStyle">#null</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">#android:color/transparent</item>
Using below also works
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:background">#android:color/transparent</item>
Also You can set in your code by using
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
and this should be before setContentView
dialog.setContentView(R.layout.dialog);
I had the exact same symptom but for me it was actually that I had used the standard frameworks AlertDialog (and its Builder) instead of android.support.v7.app.AlertDialog, switching to use the one from the support library fixed the issue for me.
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>