Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

Styling of AlertDialog buttons #827

Open
4nd3250n opened this issue May 4, 2014 · 0 comments
Open

Styling of AlertDialog buttons #827

4nd3250n opened this issue May 4, 2014 · 0 comments

Comments

@4nd3250n
Copy link

4nd3250n commented May 4, 2014

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant