问题
I am using tabLayout as
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayoutSubscriptionDays"
style="@style/CustomTabLayoutTextSizeSix"
android:layout_width="match_parent"
android:layout_height="@dimen/_40sdp"
android:background="@color/white"
app:tabBackground="@color/selector_tab_blue_white"
app:tabIndicatorColor="@color/transparent"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/white"
app:tabTextColor="@color/black" />
In some devices i am getting exception as like : android.content.res.Resources$NotFoundException: File res/color/selector_tab_blue_white.xml from drawable resource ID #0x7f0601d8
This is my selector which is in color directory:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/blue_4880ff" android:state_selected="true" />
<item android:color="@color/white" />
</selector>
I have tried so many solutions regarding this like:
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
These solutions I have tried.
If anyone can help then it will be so good. Thanks
回答1:
You have to add that drawable file in 2 folders along with drawable folder:
drawable
drawable-v24
Then it will not crash on any device.
Hope this helps
回答2:
Please Follow below steps to resolve this issue ..
- first check this file is present in project or not
- now sync your gradle
- Click on clean project
- Click on Rebuild project
- Invalidate Caches/Restart
- Re-run project
来源:https://stackoverflow.com/questions/61651613/exception-android-content-res-resourcesnotfoundexception-file-res-color-select