In the process of developing with Android studio, I wanted to do something to get rid of the above line when I encountered deprecated, deprecated methods and classes. Then, it's been a long time since the problem was not a problem.
Before we created the fixed tabs, it was similar to this feature,
It's actionbar.tab. but Actionbar deprecated. So what's the new solution? Tablayout+viewpager can achieve the above functions
Error occurred: android.view.InflateException:Binary XML file line #8: Error inflating class Android.support.design
First of all, I made it clear that my SDK was upgraded to more than 21 versions. The support Library is also up-to-date.
Add Dependencies 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 '}
Activity_main.xml content is as follows:
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:app= "http// Schemas.android.com/apk/res-auto " android:layout_width=" match_parent " android:layout_height=" Match_ Parent " android:orientation=" vertical "> <android.support.design.widget.tablayout android:id= "@+id/sliding_tabs" android:layout_width= "match_parent" android:layout_height= "Wrap_content" app: Tabmode= "scrollable"/> <android.support.v4.view.viewpager android:id= "@+id/viewpager" Android:layout_width= "Match_parent" android:layout_height= "0px" android:layout_weight= "1" Android:background= "@android: Color/white"/></linearlayout>
Error message Tip:
caused by:android.view.InflateException:Binary XML file line #8: Error inflating class an Droid.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.Lay Outinflater.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.setC Ontentview (activity.java:2144) at Com.example.hp.myapplication.MainActivity.onCreate (mainactivity.java:15) A T Android.app.Activity.performCreate (activity.java:5933)
The error indicated above is that in the 8th line of the XML file, a inflate error occurs and then causes the mainactivity.java:15 in the line
Setcontentview (r.layout. Activity_main);
error.
Ways to resolve errors:
In Styles.xml in res/values, you need to modify the parent's property value and not use a custom.
There are two styles.xml that need to be modified.
To modify the content, refer to the following:
<resources> <style name= "Apptheme" parent= "Base.apptheme" > <!--Customize your theme here.-- > </style> <!--Base Application theme- <style name= "Base.apptheme" parent= " Theme.AppCompat.Light.DarkActionBar "> <item name=" colorprimary "> #673AB7 </item> <item Name= "Colorprimarydark" > #512DA8 </item> <item name= "coloraccent" > #FF4081 </item> </style></resources>
modifies the property value in the parent, as defined above
<resources> <style name= "Apptheme" parent= "Base.apptheme" > </style></resources >
The result was solved successfully.
Similar questions reference link: http://stackoverflow.com/questions/30547323/ error-when-using-any-android-design-support-library-elements/30557995#30557995
Error referencing the Android design package