I am developing an Android app which doesn't require backward compatibility. Target SDK version is 22 as of now. I am using native Activity and Fragment and application theme is android:Theme.Material.Light. My problem is that I'm not able to use Snackbar with the existing setup, it throws exceptions like
android.view.InflateException: Binary XML file line #18: Error inflating class android.support.design.widget.Snackbar$SnackbarLayout E/AndroidRuntime(19107): at android.view.LayoutInflater.createView(LayoutInflater.java:640) E/AndroidRuntime(19107): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:750)
I googled but couldn't find any example of snackbar with Activity. So is it necessary to use support library like
AppCompatActivity or android.support.v4.app.Fragment.
in order to use Snackbar in my app?
If you're stubborn like me and you don't want to use the support libs, but want to use the snackbar in your app, there is an option for you. I found this deprecated library that is essentially the Snackbar you know, just independent from the support libs. It works fine for me, however it might not have some features such as moving a FloatingActionButton upwards when appearing.
You need to use the support design library
compile 'com.android.support:design:23.0.1'
for it to work:(Read more in detail here)
Yes, add dependencies on your gradle
Then, change your app theme accordingly, you need to use the
AppCompat
theme. Create the following theme on yourStyles.xml
In your manifest then: add
@style/AppTheme
on application and add@style/AppTheme.NoActionBar
on every activity