Τρίτη 14 Φεβρουαρίου 2017

How to customise Digits Country Code Picker

I would like to share with you, the solution of how to theme the Country Code picker that open in Digits. Digits has documented on how to theme most parts of the basic UI, but they have left out the country picker! In first glance, you assume that it is simply a Spinner so you try to theme it as such but you fail, since it is TextView that opens and AlertDialog when you tap it!


SOLUTION:
In your custom theme, e.g. DigitsTheme, include the item name android:alertDialogTheme and set as value something like @style/DigitsDialogCustom then append in your styles.xml file another style that looks like the following:
<style name="DigitsDialogCustom" parent="@android:style/Theme.Dialog"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:background">@android:color/black</item> </style>
That is it! You now have a country picker that has black background!

Full styles.xml:
xml version="1.0" encoding="UTF-8"?> <resources> <style name="BaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"> </style> <style name="AppTheme" parent="BaseTheme"> <item name="android:windowNoTitle">true</item> <item name="android:textColorPrimary">@android:color/white</item> <item name="android:textColorSecondary">@android:color/white</item> <item name="android:windowBackground">@android:color/black</item> <item name="android:textColorLink">#009996</item> <item name="android:colorAccent">#009996</item> <item name="android:popupBackground">#838383</item> <item name="android:alertDialogTheme">@style/DigitsDialogCustom</item> </style> <style name="DigitsDialogCustom" parent="@android:style/Theme.Dialog"> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:background">@android:color/black</item> </style> </resources>

LinkWithin

Blog Widget by LinkWithin

Mobile edition