Error in referencing Android Design package
When using Android Studio for development, when encountering obsolete and unrecommended methods and classes, I want to do something to remove the above line. Then, I was troubled by a problem that was not a problem for a long time.
Previously, when we created a fixed Tabs, this function was similar,
ActionBar. Tab is used, but ActionBar deprecated is used. So what is a new solution? TabLayout + ViewPager can implement the above functions
Error: android. view. InflateException: Binary XML file line #8: Error inflating class android. support. design
First, I made it clear that my sdk has been upgraded to version 21 or later. The support Library is also up-to-date.
Add dependency in Android studio
Build. gradle (Module. app)
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.android.support:support-v4:22.2.0' compile 'com.android.support:design:22.2.0'}
The content of activity_main.xml is as follows:
Error message:
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class android.support.design.widget.TabLayout at android.view.LayoutInflater.createView(LayoutInflater.java:633) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:377) at android.app.Activity.setContentView(Activity.java:2144) at com.example.hp.myapplication.MainActivity.onCreate(MainActivity.java:15) at android.app.Activity.performCreate(Activity.java:5933)
The error shown above is that an Inflate error occurs in row 8th of the xml file, which causes the error in line 15 of MainActivity. java:
setContentView(R.layout.activity_main);
Error.
Solution:
In styles. xml of res/values, you need to modify the attribute value of parent. You cannot use custom attributes.
Two styles. xml must be modified.
For more information, see:
Modify the property value in the parent.
The result is successfully resolved.
Reference for similar issues: http://stackoverflow.com/questions/30547323/error-when-using-any-android-design-support-library-elements/30557995#30557995