美文网首页
NavigationView 兼容系列报错

NavigationView 兼容系列报错

作者: zhongjh | 来源:发表于2017-03-05 00:22 被阅读171次

最近发布到百度平台的app出现一个兼容的问题,甚是奇怪,网上也没查到想要的答案。
报错信息:
Binary XML file line #30: Error inflating class android.support.design.widget.NavigationView

经过一系列一晚上的排查(我的周末)。。。发现最终是这段代码引起的

<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="@dimen/nav_header_height"
  android:background="@drawable/side_nav_bar"
  android:gravity="bottom"
  android:orientation="vertical"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:theme="@style/ThemeOverlay.AppCompat.Dark">

具体是这个代码

  android:background="@drawable/side_nav_bar"

点击side_nav_bar进去是这个

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:angle="135"
        android:centerColor="#4CAF50"
        android:endColor="#2E7D32"
        android:startColor="#81C784"
        android:type="linear" />
</shape>

后来google之后
http://stackoverflow.com/questions/35472963/android-kitkat-android-view-inflateexception-error-inflating-class-android-sup

不管是保留drawable还是创建多一个drawable-v21,还是不行,最后迫于无奈还是换了图片,不使用这个渐变xml了

最后发这个兼容真机测试网址:
http://mtc.baidu.com/report/summary/t/228045?viewFrom=taskLists

对了,就连官方创建的demo,在红米也报错~~

相关文章

网友评论

      本文标题:NavigationView 兼容系列报错

      本文链接:https://www.haomeiwen.com/subject/hmcsgttx.html