Reputation: 499
When I create a snackbar on Android I get this error: "java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity".
I don't want to change the theme to AppCompat of my activity, Is there a way I can have the snackbar without changing the theme?
Upvotes: 4
Views: 641
Reputation: 1007554
Either you are using appcompat-v7
(AppCompatActivity
, Theme.AppCompat
, etc.), or you are not. You need to be consistent, so if you are not going to use Theme.AppCompat
, make sure you are not extending AppCompatActivity
.
However, the Design Support library — the source of the official Snackbar
— only supports activities using appcompat-v7
. If you want a snackbar without appcompat-v7
, you cannot use the Design Support library. Instead, use some other implementation of a snackbar.
I just released a library that offers a port of the official Snackbar
that works without appcompat-v7
, but it only works with projects that have minSdkVersion
of 21 or higher. This library implements a snackbar that works on older devices, though the project is discontinued. There may be other implementations.
Upvotes: 4