How do you set DialogFragment.STYLE_NO_FRAME in styles.xml? - android

How do you set DialogFragment.STYLE_NO_FRAME, which hides the frame, in your styles.xml file? Or does this have to be done outside of the xml file?

Have a look at this link.
Put STYLE_NO_FRAME in styles.xml
<style name="DialogWindowAnim">
<item name="android:windowFrame">#null</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowEnterAnimation">#anim/slide_up_from_bottom</item>
<item name="android:windowExitAnimation">#anim/slide_down_to_bottom</item>
</style>
<style name="DialogSlideAnim" parent="DialogWindowAnim">
<item name="android:windowAnimationStyle">#style/DialogWindowAnim</item>
</style>
This is how I did it.

Related

Change my customize theme into transparent theme for my activity

I have this customized theme which I want to convert into Transparent theme
<resources>
<style name="MyMaterialTheme" parent="MyMaterialTheme.Base"></style>
<style name="MyMaterialTheme.Base"
parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item> </style>
</resources>
Do the following
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<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>
</style>
</resources>
The value #color/transparent is the color value #00000000 which I put in res/values/color.xml file. You can also use #android:color/transparent in later Android versions.
Then apply the style to your Activity, for example:
<activity android:name=".SampleActivity" android:theme="#style/Theme.Transparent">
...
</activity>
Add this style in your `values/styles.xml
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
And the following in `values/styles.xml
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
Try putting these items
<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>

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>

Can not use windowFullscreen to Android Dialog

When I creat a Dialog with follow styles:
<style name="Transparent">
<item name="android:windowBackground">#drawable/transparent_background</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">#+android:style/Animation.Translucent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowFullscreen">true</item>
</style>
I found that windowFullscreen item could not work!!
How can I creat a floating Dialog with fullscreen just like this:
http://i.stack.imgur.com/5Zshd.jpg

Why doesn't theme inherit button style

I am having a problems with my Transparent style inheriting the button style from the parent style (AppTheme). The button has a different style in the TransparentActivity theme.
Here are my styles, with a few items removed for simplicity.
<?xml version="1.0" encoding="utf-8"?>
<!-- Generated with http://android-holo-colors.com -->
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppTheme" parent="#style/_AppTheme"/>
<style name="_AppTheme" parent="android:Theme.Light">
...
<item name="android:buttonStyle">#style/ButtonAppTheme</item>
...
</style>
<style name="TransparentActivity" parent="AppTheme">
<item name="android:windowBackground">#color/Trans60</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowFullscreen">false</item>
</style>
</resources>
Try using #android:style/Theme.NoDisplay
So change :
<style name="TransparentActivity" parent="AppTheme">
<item name="android:windowBackground">#color/Trans60</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowFullscreen">false</item>
</style>
To
<style name="TransparentActivity" parent="#android:style/Theme.NoDisplay">
<item name="android:buttonStyle">#style/ButtonAppTheme</item>
<item name="android:textColor">#android:color/white</item>
</style>

How to define a new theme and override the alert dialog style in framework

I want to define a new theme in my app, and override the default Holo AlertDialog style. But there's no way I can change the background or layout of my dialogs.
I followed partly the advice of this blog post.
These are the themes:
<style name="CD1.Theme" parent="android:style/Theme.Holo">
<!-- AlertDialog attributes -->
<item name="android:alertDialogTheme">#style/CD1.Theme.Dialog.Alert</item>
<item name="android:alertDialogStyle">#style/CD1.AlertDialog</item>
<item name="android:alertDialogCenterButtons">false</item>
<item name="android:alertDialogIcon">#drawable/cd1_ic_dialog_alert_holo</item>
</style>
<style name="CD1.Theme.Dialog.Alert" parent="android:style/Theme.Holo.Dialog.Alert">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowTitleStyle">#style/CD1.DialogWindowTitle</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowMinWidthMajor">#android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">#android:dimen/dialog_min_width_minor</item>
</style>
These are the styles:
<style name="CD1.AlertDialog" parent="android:style/AlertDialog.Holo">
<item name="android:fullDark">#drawable/cd1_dialog_full_holo</item>
<item name="android:topDark">#drawable/cd1_dialog_top_holo</item>
<item name="android:centerDark">#drawable/cd1_dialog_middle_holo</item>
<item name="android:bottomDark">#drawable/cd1_dialog_bottom_holo</item>
<item name="android:fullBright">#drawable/cd1_dialog_full_holo</item>
<item name="android:topBright">#drawable/cd1_dialog_top_holo</item>
<item name="android:centerBright">#drawable/cd1_dialog_middle_holo</item>
<item name="android:bottomBright">#drawable/cd1_dialog_bottom_holo</item>
<item name="android:bottomMedium">#drawable/cd1_dialog_bottom_holo</item>
<item name="android:centerMedium">#drawable/cd1_dialog_middle_holo</item>
<item name="android:layout">#layout/cd1_alert_dialog</item>
</style>
<style name="CD1.DialogWindowTitle" parent="android:style/DialogWindowTitle.Holo">
<item name="android:maxLines">1</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:textAppearance">#android:style/TextAppearance.Holo.DialogWindowTitle</item>
<item name="android:gravity">center</item>
</style>
It doesn't work. The default Holo layout is still displayed. What should I do?
Thanks.
Move <item name="android:alertDialogStyle">#style/CD1.AlertDialog</item> from CD1.Theme to CD1.Theme.Dialog.Alert:
<style name="CD1.Theme" parent="android:style/Theme.Holo">
<!-- AlertDialog attributes -->
<item name="android:alertDialogTheme">#style/CD1.Theme.Dialog.Alert</item>
<item name="android:alertDialogCenterButtons">false</item>
<item name="android:alertDialogIcon">#drawable/cd1_ic_dialog_alert_holo</item>
</style>
<style name="CD1.Theme.Dialog.Alert" parent="android:style/Theme.Holo.Dialog.Alert">
<item name="android:alertDialogStyle">#style/CD1.AlertDialog</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowTitleStyle">#style/CD1.DialogWindowTitle</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowMinWidthMajor">#android:dimen/dialog_min_width_major</item>
<item name="android:windowMinWidthMinor">#android:dimen/dialog_min_width_minor</item>
</style>
By the way:
android:layout attribute requires API 11.
If you are developing against SDK which is below 11 your can consider this project:
https://github.com/fengdai/AlertDialogPro

Categories

Resources