Binary XML file line #10: Error inflating class android.support.design.widget.TabLayout

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014360817/article/details/61400174

崩溃日志

Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class android.support.design.widget.TabLayout
                at android.view.LayoutInflater.createView(LayoutInflater.java:637)
                at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)
                at android.view.LayoutInflater.rInflate(LayoutInflater.java:810)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:508)
                at android.view.LayoutInflater.inflate(LayoutInflater.java:418)
                <此处省略>
Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
               at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:36)
                <此处省略>

出现原因

TabLayout为5.0之后的新控件,在使用时Activity使用主题不当造成

解决办法

解决办法第二句Caused by已经给出方案,需要使用Theme.AppCompat 或者继承自Theme.AppCompat, 还有一个方法,如果没有必要使用主题直接不引用theme即可,配置只需在AndroidManifest.xml处理即可 如下:

第一种不适用主题:
<activity
    android:name=".fragment.resource.InformationActivity"
    android:launchMode="singleTask"
    android:screenOrientation="portrait"
    android:windowSoftInputMode="adjustResize" />
第二种自定义主题必须使用Thme.AppCompat 或者继承自Theme.AppCompat:
<activity
   android:name=".fragment.resource.InformationActivity"
   android:launchMode="singleTask"
   android:screenOrientation="portrait"
   android:theme="@style/custom_style"
   android:windowSoftInputMode="adjustResize" />

更多内容访问:个人站点

猜你喜欢

转载自blog.csdn.net/u014360817/article/details/61400174