I want to make two skin application and fast change background in dialogs.
I have DialogFragments and when i want to display my own theme i do it by:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.MyDialog);
And in styles.xml i have:
<style name="MyDialog" parent="#android:style/Theme.Holo.Dialog">
<item name="android:background">#color/background_black</item>
<item name="android:windowBackground">#null</item>
<item name="android:windowFrame">#null</item>
</style>
but it's doesn't works.
How to remove that second background selected here:
http://i62.tinypic.com/2i29dzr.png
background between yellow lines
As for me I'm using this style to remove background of dialog, and it works for me perfectly:
<style name="CustomDialog" parent="#android:style/Theme.Holo.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:background">#android:color/transparent</item>
<item name="background">#android:color/transparent</item>
</style>
Related
I have a Custom Dialog and I'm trying to change the background color of the title bar, but it doesn't work.
This is my styles.xml
<style name="WindowTitleBackground">
<item name="android:background">#color/PaleBlue</item>
</style>
<style name="availabilityDialog" parent="Theme.AppCompat.Dialog">
<item name="windowNoTitle">false</item>
<item name="windowTitleBackgroundStyle">#style/WindowTitleBackground</item>
</style>
I apply it as a theme to an activity in my manifest.
<activity android:name=".activities.ChangeAvailabilityActivity"
android:theme="#style/availabilityDialog">
</activity>
The picture below shows the result
The color remains black/grey. I have tried different colors, setting actionBarStyle and windowTitleStyle to WindowTitleBackground etc. No luck.
try this:
in your res/values/styles:
<style name="custom_dialog" parent="#android:style/Theme.Dialog">
<item name="android:windowTitleStyle">#style/dialog_title_style</item>
</style>
<style name="dialog_title_style" parent="android:Widget.TextView">
<item name="android:background">#android:color/black</item> //change background color here
<item name="android:padding">10dp</item>
</style>
And use it as:
Dialog dialog=new Dialog(this,R.style.custom_dialog);
dialog.setContentView(R.layout.your_dialog_layout);
dialog.setTitle("Example");
I am using android.app.Dialog and using setTitle("title"); method but it doesn't show the dialog title bar. I have also used the following style for that activity in menifest file.
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
May be this style automatically applies for dialog as well. How can I show the title bar without changing the windowNoTitle to false? I also don't want to use AlertDialog instead of Dialog.
You need to change your style to
Check this style may be this will work.
<style name="picture_dialog_style" parent="#android:style/Theme.Holo.Dialog.NoActionBar">
<item name="android:windowFrame">#null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">false</item>
<item name="android:background">#android:color/white</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:textColor">#color/colorOrange</item>
<!--<item name="android:windowAnimationStyle">#style/PauseDialogAnimation</item>-->
</style>
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>
I am using Accengage (Ad4Push) and I want to customize its dialog. Accengage team said that it is possible to change dialog style with custom theme and I did that. I can change textSize, textColor, windowBackground but I still see the grey color on Dialog. Please see my photo Here. (I haven't got enough reputations to post an image)
I want to change all background dialog to white, but I don't know which attribute I can use for this purpose.
This is the attribute I am using.
<style name="CustomDialogTheme" parent="#android:style/Theme.Dialog">
<item name="android:background">#color/background_holo_light</item>
<item name="android:divider">#color/background_holo_light</item>
<item name="android:dividerHorizontal">#null</item>
<item name="android:dividerVertical">#null</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:textColorPrimary">#android:color/black</item>
<item name="android:buttonBarButtonStyle">#style/CustomDialogTheme.Button</item>
<item name="android:padding">2dp</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
<style name="CustomDialogTheme.Button">
<item name="android:background">#color/background_dark</item>
<item name="android:textColor">#color/background_holo_light</item>
<item name="android:layout_margin">8dp</item>
<item name="android:layout_marginLeft">16dp</item>
<item name="android:padding">8dp</item>
<item name="android:gravity">center</item>
</style>
How I can make background of dialog become white. (I only can change the style with custom style, can not change programmatically, because this dialog come from third party library)
In onCreate add this line.
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
checkout this post.
Dialog with transparent background in Android
Your question has already been answered here
Code from the link:
Add this to your styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.DoNotDim" parent="android:Theme">
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
And then apply the theme to your activity:
<activity android:name=".SampleActivity" android:theme="#style/Theme.DoNotDim">
add this line in your theme (thanks to AAA)
<item name="android:windowBackground">#android:color/transparent</item>
full style:
<style name="CustomDialogTheme" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:background">#color/background_holo_light</item>
<item name="android:divider">#color/background_holo_light</item>
<item name="android:dividerHorizontal">#null</item>
<item name="android:dividerVertical">#null</item>
<item name="android:textColor">#android:color/black</item>
<item name="android:textColorPrimary">#android:color/black</item>
<item name="android:buttonBarButtonStyle">#style/CustomDialogTheme.Button</item>
<item name="android:padding">2dp</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?