3

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?

Greelings
  • 4,964
  • 7
  • 34
  • 70

2 Answers2

8

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);
Greelings
  • 4,964
  • 7
  • 34
  • 70
1

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>
Yoann Hercouet
  • 17,894
  • 5
  • 58
  • 85