Android : Theme.Holo VS Theme.AppCompat

11.3k Views Asked by At

I use "@android:style/Theme.Holo" as my game's theme :

enter image description here

But to be able to set up a snackbar widget, I have no choice but using "@style/Theme.AppCompat", otherwise I get this error message :

You need to use a Theme.AppCompat theme (or descendant) with the design library

The problem is that the "@style/Theme.AppCompat" is visually quite different :

enter image description here

What could I do to stay with the same visual as "@android:style/Theme.Holo", but in the same time be able to use a snackbar widget?

EDIT With the Yoann Hercouet's solution, here is the result :

enter image description here

What is missing?

2

There are 2 best solutions below

0
Greelings On BEST ANSWER

I finally found the solution :

AndroidManifest.xml :

<application
    android:theme="@style/Theme.AppCompat"
    ...

MyDialog.java :

new AlertDialog.Builder(new ContextThemeWrapper(context, android.R.style.Theme_Holo_Dialog));

Instead of :

new AlertDialog.Builder(context);
13
Yoann Hercouet On

Try updating your app theme by changing the default style for dialogs:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="alertDialogTheme">@android:style/Theme.Holo.Dialog</item>
</style>

EDIT:

Not sure why it doesn't change anything, it worked on my app, maybe try this other way and create a custom style:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="alertDialogTheme">@style/myAlertDialogStyle</item>
</style>

<style name="myAlertDialogStyle" parent="android:style/Theme.Holo.Dialog">
    ...
</style>