简体   繁体   中英

Android alerts: how to upgrade AlertDialog from old style (black) to new style (white)?

I am currently updating a old app. The alerts have an old style (quite ugly), with a black background. How to have the new white style ? (nota: it seems that using recent params in Gradle like compileSdkVersion 25, buildToolsVersion "25.0.2", targetSdkVersion 22 is not enough)

Note that my circular ProgressBars are also 'old style'.

Thanks for your help !

The theme used in the 'application' tag of my app is android:theme="@android:style/Theme.NoTitleBar"

That is the original theme from Android 1.x/2.x. Themes affect many things, including the look of alert dialogs and ProgressBar .

What should I choose instead to have a modern style compatible down to SDK 10?

Option #1: Leave it alone and live with it.

Option #2:

  • Create res/values-v13/styles.xml and create a custom theme (eg, AppTheme ) that inherits from @android:style/Theme.Holo.NoActionBar

  • Create res/values/styles.xml and create a custom theme with the same name (eg, AppTheme ) that inherits from @android:style/Theme.NoTitleBar

  • Have your <application> use your custom theme (eg, AppTheme )

This will adopt the Holo theme on API Level 13+ devices.

Option #3:

  • Do everything from Option #2

  • Also add res/values-v21/styles.xml and create a custom theme with the same name that inherits from @android:style/Theme.Material.NoActionBar

This will adopt the Holo theme on API Level 13-20 devices and the Material theme on API Level 21+ devices.

Option #4: Rewrite your app to use appcompat-v7 ( AppComaptActivity , modified menu resources, etc.) and use a suitable Theme.AppCompat -based theme. This will give you the same look on all versions, at the cost of modifying all of your activities, all of your menu resources, adding the appcompat-v7 dependency, and perhaps other changes as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM