相关疑难解决方法(0)

KitKat specific- android.content.res.Resources $ NotFoundException:来自可绘制资源ID的文件res/drawable/list_selector_white.xml

我在这里尝试了答案,但它对我不起作用.我使用xml作为背景并获得优秀 - Resources$NotFoundException: File res/drawable/list_selector_white.xml from drawable resource ID.该应用程序在发布时崩溃.

奇怪的是它在运行Lollypop的设备上运行良好.在操作系统<= KitKat上,这个问题正在重新引发.

正在片段中膨胀的XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/list_selector_white" >
    ....Other views here....
Run Code Online (Sandbox Code Playgroud)

list_selector_white.xml

<!-- Selector style for listrow -->
    <item android:drawable="@drawable/gradient_bg_white" android:state_pressed="false" android:state_selected="false"/>
    <item android:drawable="@drawable/gradient_bg_hover" android:state_pressed="true"/>
    <item android:drawable="@drawable/gradient_bg_hover" android:state_pressed="false" android:state_selected="true"/>
Run Code Online (Sandbox Code Playgroud)

gradient_bg_hover

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <!-- Gradient BgColor for listrow Selected -->
  <gradient
      android:startColor="?attr/listViewRow"
      android:centerColor="?attr/listViewRow"
      android:endColor="?attr/listViewRow"
      android:angle="270" />
</shape>
Run Code Online (Sandbox Code Playgroud)

logcat的:

E/AndroidRuntime( 3879): android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
E/AndroidRuntime( 3879):    at android.view.LayoutInflater.createView(LayoutInflater.java:620)
E/AndroidRuntime( 3879):    at …
Run Code Online (Sandbox Code Playgroud)

xml android android-layout

5
推荐指数
2
解决办法
2967
查看次数

标签 统计

android ×1

android-layout ×1

xml ×1