Friday, 2 January 2015

Theming Dialog on API 21 (Lollipop) Android



I am currently trying to theme Alert Dialogs on an android app I am making. I can theme API 9 (min for app) through API 19/20 (KitKat).


However, I cannot theme API 21 (Lollipop) correctly. I do not like the off-white/light-gray color that is the default theme, so I am trying to make the entire background white.


http://ift.tt/1BcAgDr


Sorry, I cannot post pictures yet.


I can only do a certain amount by setting the background of the layout of the dialog to white, and also the button backgrounds to a selector which is white.


There is a strip of space behind the buttons (all across the bottom) that remains the grayish color though. I have tried looking into if I can change it by theming the buttonBarStyle attribute, but haven't had any luck.


Here are some code snippets:


Theme:



<style name="myTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:alertDialogStyle">@style/AlertDialogCustom</item>
</style>


Custom Alert Dialog Theme:



<style name="AlertDialogCustom" parent="@android:style/Theme.Dialog">
<item name="android:bottomBright">@color/white</item>
<item name="android:bottomDark">@color/white</item>
<item name="android:bottomMedium">@color/white</item>
<item name="android:centerBright">@color/white</item>
<item name="android:centerDark">@color/white</item>
<item name="android:centerMedium">@color/white</item>
<item name="android:fullBright">@color/white</item>
<item name="android:fullDark">@color/white</item>
<item name="android:topBright">@color/white</item>
<item name="android:topDark">@color/white</item>
</style>


I have tried some things like this inside the Dialog theme. Nothing has worked:



<item name="android:background">@color/white</item>
<item name="android:colorBackground">@color/white</item>
<item name="android:buttonBarStyle">@style/CustomButtonBarStyle</item>


CustomButtonBarStyle:



<style name="CustomButtonBarStyle" parent="@android:style/ButtonBar">
<item name="android:background">@color/white</item>
<item name="android:divider">@color/white</item>
</style>


Any help would be appreciated!


No comments:

Post a Comment