Ripple requires API level 21 (current min is 11), android?

白昼怎懂夜的黑 提交于 2020-01-03 09:30:23

问题


I have the below drawable

<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:colorControlHighlight" >

<item>
    <shape android:shape="oval" >
        <solid android:color="?android:colorAccent" />
    </shape>
</item>

And I am getting this error

<ripple> requires API level 21 (current min is 11)

How do I solve it?


回答1:


You are using minsdk=11.

You can't use this drawable with api<21.

You have to use diffent versions of this drawable file.
Put this code in res/drawable-v21/myRipple.xml and create a different res/drawable/myRipple.xml




回答2:


While it's true that the tag was added in API 21, RippleDrawable is pretty simple and it's possible to port it back to API 1. There's a good number of libraries backporting the ripple for older devices. For a sample implementation see:

https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/drawable/ripple/RippleDrawableICS.java



来源:https://stackoverflow.com/questions/29179890/ripple-requires-api-level-21-current-min-is-11-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!