Thursday 1 October 2015

Error:Error inflating class android.support.design.widget.TabLayout

While creating tab layout in version higher than api level 21 in android, Sometime we get the error

Error inflating class android.support.design.widget.TabLayout.

The Reason is that tab layout widget provided by android design library need a style attribute for that tab layout. Basically it needs a indicator color for that tab layout. Suppose this is your tab layout file.



In above file, You have a tab layout widget. But you haven't specified the style attribute for that.


For using material design theme you have to add a new styles.xml file in res folder. But first you need to add a folder values-v21 in app/res folder for using material design. Then create an xml file named styles.xml in that values-v21 folder. Add following code in that file.



Now add the style "MyCustomTabLayout" attribute in your viewpager or tab layout file.



Now build the project again and run. You will not get that error now.

I hope it helps. If you like the post share , like and comment. If you have any other doubt comment.
For more post like this subscribe to right of the webpage.
Like my facebook page : https://www.facebook.com/geeksmember?fref=ts&ref=br_tf

Related Posts

Related Posts Plugin for WordPress, Blogger...