I have created a custom progress dialog drawables.
<style name="MyTheme" parent="#android:style/Theme.Dialog">
<item name="android:alertDialogStyle">#style/CustomAlertDialogStyle</item>
<item name="android:textColorPrimary">#ABCDEF</item>
<item name="android:textColor"> #color/heading</item>
<item name="android:background">#00000000</item>
<item name="android:windowFrame">#null</item>
</style>
<style name="CustomAlertDialogStyle">
<item name="android:background">#00000000</item>
<item name="android:windowFrame">#null</item>
<item name="android:bottomBright">#color/grey</item>
<item name="android:bottomDark">#color/grey</item>
<item name="android:bottomMedium">#color/grey</item>
<item name="android:centerBright">#color/grey</item>
<item name="android:centerDark">#color/grey</item>
<item name="android:centerMedium">#color/grey</item>
<item name="android:fullBright">#color/grey</item>
<item name="android:fullDark">#color/grey</item>
<item name="android:topBright">#color/grey</item>
<item name="android:topDark">#color/grey</item>
</style>
Everything is working fine, its showing the things as it should. But dialog is showing borders. I want to remove those borders [screen shot attached].
use dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
You need to add the following to your CustomAlertDialogStyle too:
<item name="android:windowBackground">#android:color/transparent</item>
Related
I have attached the screenshot showing what I want to achieve. I want to achieve just one background for my popup menu. Now as you can see on the picture below my menu there is a second background? I want toi stay this one below (darker one) with rounded corners. How to fix this?
I am adding my style.xml
<style name="objectsmeasure_dark" parent="Theme.MaterialComponents.NoActionBar">
<item name="colorPrimary">#color/a212121</item>
<item name="colorPrimaryDark">#android:color/black</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:alertDialogTheme">#style/alert_dialog_dark</item>
<item name="android:windowBackground">#color/colorWindowBackgroundNight</item>
<item name="colorBg">#color/colorWindowBackgroundNight</item>
<item name="colorBottomNavigationViewBg">#color/bottom_nav_view_bg_night</item>
<item name="colorBottomNavigationViewItem">#color/bottom_nav_view_item_night</item>
<item name="android:popupMenuStyle">#style/popup_menu_dark</item>
<item name="popupMenuStyle">#style/popup_menu_dark</item>
<item name="myBackgroundColor">#color/colorGrey</item>
<item name="myEtBackgroundColor">#color/BF606060</item>
<item name="myCardBackground">#color/a212121</item>
<item name="myTextColor">#android:color/white</item>
<item name="myTintColor">#android:color/white</item>
<item name="myButtonColor">#color/colorButton</item>
<item name="myHintTextColor">#color/B3FFFFFF</item>
<item name="android:navigationBarColor">#android:color/black</item>
<item name="dialogTheme">#style/dialog_dark</item>
<item name="android:dialogTheme">#style/dialog_dark</item>
<item name="android:windowContentTransitions">true</item>
<item name="currentTheme">#style/objectsmeasure_dark</item>
</style>
<style name="popup_menu_dark" parent="Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">#color/dark</item>
</style>
<style name="alert_dialog_dark" parent="Theme.MaterialComponents.Dialog.Alert">
<item name="colorPrimary">#color/colorButton</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:background">#color/dark</item>
<item name="background">#color/dark</item>
<item name="buttonBarPositiveButtonStyle">#style/alert_dialog_button_positive</item>
<item name="buttonBarNegativeButtonStyle">#style/alert_dialog_button_negative</item>
</style>
<style name="dialog_dark" parent="Theme.MaterialComponents.Dialog">
<item name="colorPrimary">#color/colorButton</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="android:background">#color/dark</item>
<item name="background">#color/dark</item>
<item name="buttonBarPositiveButtonStyle">#style/alert_dialog_button_positive</item>
<item name="buttonBarNegativeButtonStyle">#style/alert_dialog_button_negative</item>
</style>
Thank you for any help.
I solved this issue. It turned out I mixed parent styles - MaterialComponents and AppCompat and once I standarize it the problem was gone.
I use bellow style to change Dialog background color to dark, In preference page I use ListPreference and after apply this style, cancel button of ListPreference disappeared in dialog background.
<style name="AppThemeBase" parent="Theme.MaterialComponents.DayNight">
<item name="colorPrimary">#212D3B</item>
<item name="colorPrimaryDark">#172331</item>
<item name="colorAccent">#61A3D7</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:dialogTheme">#style/AppTheme.Dialog</item>
<item name="android:alertDialogTheme">#style/AppTheme.Dialog</item>
</style>
<style name="AppTheme.Dialog" parent="Theme.MaterialComponents.DayNight.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:background">#212D3B</item>
<item name="colorPrimary">#61A3D7</item>
<item name="colorPrimaryDark">#8DB2D3</item>
<item name="colorAccent">#61A3D7</item>
</style>
Is there a way to change this button color?
Finally I found solution. I don't understand what is different between android:alertDialogTheme and alertDialogTheme (without android:) but preference screen used the alertDialogTheme to stylize dialogs.
By adding bellow item to AppThemeBase, my problem is resolved.
<item name="alertDialogTheme">#style/AppTheme.Dialog</item>
Final AppThemeBase :
<style name="AppThemeBase" parent="Theme.MaterialComponents.DayNight">
<item name="colorPrimary">#212D3B</item>
<item name="colorPrimaryDark">#172331</item>
<item name="colorAccent">#61A3D7</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:dialogTheme">#style/AppTheme.Dialog</item>
<item name="android:alertDialogTheme">#style/AppTheme.Dialog</item>
<item name="alertDialogTheme">#style/AppTheme.Dialog</item>
</style>
<style name="AppTheme.Dialog" parent="Theme.MaterialComponents.DayNight.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:background">#212D3B</item>
<item name="colorPrimary">#61A3D7</item>
<item name="colorPrimaryDark">#8DB2D3</item>
<item name="colorAccent">#61A3D7</item>
</style>
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
This question already has answers here:
Change background of ProgressDialog
(2 answers)
Closed 8 years ago.
I used the following code to change the background of Progress Dialog. But the color changes on the outside frame too as below. I want to change only inside the dialog.
<style name="StyledDialog" parent="#android:style/Theme.Panel">
<item name="android:background">#083044</item>
</style>
As per the answer given at this question Change background of ProgressDialog
<style name="StyledDialog" parent="#android:style/Theme.Dialog">
<item name="android:alertDialogStyle">#style/CustomAlertDialogStyle</item>
<item name="android:textColorPrimary">#000000</item>
</style>
<style name="CustomAlertDialogStyle">
<item name="android:bottomBright">#color/background</item>
<item name="android:bottomDark">#color/background</item>
<item name="android:bottomMedium">#color/background</item>
<item name="android:centerBright">#color/background</item>
<item name="android:centerDark">#color/background</item>
<item name="android:centerMedium">#color/background</item>
<item name="android:fullBright">#color/background</item>
<item name="android:fullDark">#color/background</item>
<item name="android:topBright">#color/background</item>
<item name="android:topDark">#color/background</item>
</style>
This code gives background color perfect. But since, dialog color and activity's background color is same. It appears like transparent with no border. I want some border as before.
<style name="CustomAlertDialogStyle">
<item name="android:bottomBright">#color/transparent</item>
<item name="android:bottomDark">#color/transparent</item>
<item name="android:bottomMedium">#color/transparent</item>
<item name="android:centerBright">#color/transparent</item>
<item name="android:centerDark">#color/transparent</item>
<item name="android:centerMedium">#color/transparent</item>
<item name="android:fullBright">#color/transparent</item>
<item name="android:fullDark">#color/transparent</item>
<item name="android:topBright">#color/transparent</item>
<item name="android:topDark">#color/transparent</item>
</style>
<style name="StyledDialog" parent="#android:style/Theme.Panel">
<item name="android:alertDialogStyle">#style/CustomAlertDialogStyle</item>
<item name="android:background">#color/darkblue</item>
</style>
Try like this.
<style name="StyledDialog" parent="#android:style/Theme.Panel">
<item name="android:background">#android:color/transparent</item>
<item name="android:alertDialogStyle">#style/CustomStyle</item>
</style>
<style name="CustomStyle">
<item name="android:bottomBright">#083044/item>
<item name="android:bottomDark">#083044</item>
<item name="android:bottomMedium">#083044</item>
<item name="android:centerBright">#083044</item>
<item name="android:centerDark">#083044</item>
<item name="android:centerMedium">#083044</item>
<item name="android:fullBright">#083044</item>
<item name="android:fullDark">#083044</item>
<item name="android:topBright">#083044</item>
<item name="android:topDark">#083044</item>
</style>
In my application I use holoeverywhere. I would like to change the appearance of AlertDialog and I got stuck on buttons below alert dialog. I took a look how things were done in holoeverywhere and I tried to modify that.
Here is backtracking of my reasoning:
In theme there are atributes which define alertDialogTheme and some other stuff. We will come back later to selectableItemBackground also.
<style name="Holo.Base.Theme" parent="Theme.AppCompat">
...
<item name="alertDialogTheme">#style/Holo.Theme.Dialog.Alert</item>
...
<item name="buttonBarButtonStyle">?borderlessButtonStyle</item>
...
<item name="selectableItemBackground">#drawable/item_background_holo_dark</item> *
...
</sytle>
So i figure alertDialogStyle is my target which is further defined in styles:
<style name="Holo.Base.Theme.Dialog" parent="Holo.Theme">
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowAnimationStyle">#style/Holo.Animation.Dialog</item>
<item name="android:windowBackground">#drawable/dialog_full_holo_dark</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowFrame">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:windowTitleStyle">#style/Holo.DialogWindowTitle</item>
<item name="borderlessButtonStyle">#style/Holo.Button.Borderless.Small</item>
<item name="buttonBarStyle">#style/Holo.ButtonBar.AlertDialog</item>
<item name="listPreferredItemPaddingLeft">16dip</item>
<item name="listPreferredItemPaddingRight">16dip</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
<item name="windowAnimationStyle">#style/Holo.Animation.Dialog</item>
<item name="windowContentOverlay">#null</item>
<item name="windowMinWidthMajor">#dimen/dialog_min_width_major</item>
<item name="windowMinWidthMinor">#dimen/dialog_min_width_minor</item>
<item name="windowNoTitle">true</item>
</style>
<style name="Holo.Theme.Dialog" parent="Holo.Base.Theme.Dialog" >
</style>
<style name="Holo.Theme.Dialog.Alert" parent="Holo.Theme.Dialog">
<item name="alertDialogStyle">#style/Holo.AlertDialog</item>
<item name="alertDialogTitleDividerColor">#color/holo_blue_light</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
<style name="Holo.Button.Borderless" parent="Holo.Button">
<item name="android:background">?selectableItemBackground</item>
<item name="android:paddingLeft">4dip</item>
<item name="android:paddingRight">4dip</item>
</style>
So Holo.Theme.Dialog.Alert is inherited from Holo:base.Theme.Dialog which has an atribute for borderlessButtonStyle, which I guess defines the buttons of alert dialog.
Style Holo.Button.Borderless referes the atribute selectableItemBackground for its background. Atribute is set in application theme itself. So, my reasoning is if I inherit from theme Holo.theme and set selectableBackground atribut my change should reflect in customized alert dialog buttons and everything else where this background is used.
<style name="ThemeCustom" parent="#style/Holo.Theme>
…
<item name="selectableItemBackground">#drawable/custom_item_background </item>
…
</style>
But this does not work. No change is visible in alert dialog buttons. Is there something wrong with my reasoning?