Search code examples
androidandroid-5.0-lollipopandroid-alertdialogandroid-4.2-jelly-bean

Using AlertDialog style of Kitkat on Lollipop based phones


I have the same app running perfectly on both Lollipop based android phone as well as a Jellybean based android phone. However the alert dialog styles ( default) are not the same, and the dialog appear ugly in Lollipop phones.

A simple example:

In Jellybean based phone :

In Jellybean based phone

In Lollipop based phone :

In Lollipop based phone

Is it possible for me to use the alert dialog styles of older Android OS on my Lollipop based phones?

How to do this in the app programmatically?


Solution

  • You can specify the Dialog's theme by setting the second constructor parameter of your AlertDialog or AlertDialog.Builder to AlertDialog.THEME_HOLO_LIGHT:

    new AlertDialog.Builder(context, AlertDialog.THEME_HOLO_LIGHT);