天天看點

android.content.res.Resources$NotFoundException: Resource is not a Drawable

這篇文章主要是對這個錯誤進行一個記錄!

  • 首先是這個錯誤的發生場景:

    在Android的Project裡面的res檔案夾下有個專門放置xml資源的的drawable檔案夾,這個檔案夾不止一個,還有drawable-v24檔案夾,做底部導航欄時,如果引用的drawable中的xml檔案是位于drawable-v24檔案夾下,就會出現這樣的錯誤!所說的引用的xml檔案就是此屬性引用的xml檔案:

  • 這裡是代碼:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.weibo.meishijie.mvp.view.activity.MainActivity">

    <FrameLayout
        android:id="@+id/fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"></FrameLayout>

    <RadioGroup
        android:id="@+id/bottom_navbar"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:orientation="horizontal">

        <com.weibo.meishijie.mvp.view.widget.Nav_RadioButton
            android:id="@+id/rb_recommend"
            style="@style/bottom_bar_radiobutton_style"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:checked="true"
            android:text="推薦"
            app:DrawableSize="30dp"
            app:DrawableTop="@drawable/main_tab_recommend_selector" />

        <com.weibo.meishijie.mvp.view.widget.Nav_RadioButton
            android:id="@+id/rb_discovery"
            style="@style/bottom_bar_radiobutton_style"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="發現"
            app:DrawableSize="30dp"
            app:DrawableTop="@drawable/main_tab_discover_selector" />

        <com.weibo.meishijie.mvp.view.widget.Nav_RadioButton
            android:id="@+id/rb_store"
            style="@style/bottom_bar_radiobutton_style"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="商城"
            app:DrawableSize="30dp"
            app:DrawableTop="@drawable/main_tab_store_selector" />

        <com.weibo.meishijie.mvp.view.widget.Nav_RadioButton
            android:id="@+id/rb_topic"
            style="@style/bottom_bar_radiobutton_style"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="食話"
            app:DrawableSize="30dp"
            app:DrawableTop="@drawable/main_tab_topic_selector" />

        <com.weibo.meishijie.mvp.view.widget.Nav_RadioButton
            android:id="@+id/rb_mine"
            style="@style/bottom_bar_radiobutton_style"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:text="我的"
            app:DrawableSize="30dp"
            app:DrawableTop="@drawable/main_tab_mine_selector" />

    </RadioGroup>

</LinearLayout>
           
android.content.res.Resources$NotFoundException: Resource is not a Drawable