api< 21的可绘制着色 [英] Drawable tinting for api <21
本文介绍了api< 21的可绘制着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使api< 21吗?
Is it possible to make drawable tinting work for api < 21?
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/ic_calendar"
android:tint="@color/primary" />
工作正常,但仅适用于具有API21的设备.较低api设备或AppCompat支持的任何解决方法?找不到任何东西.
Works just fine but only for devices with API21. Any workaround for lower api devices or AppCompat support? Can't find anything.
推荐答案
使用AppCompatImageView
就像这样:
<android.support.v7.widget.AppCompatImageView
android:id="@+id/my_appcompat_imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/my_image"
android:tint="#636363"
/>
确保在应用程序的build.gradle
中具有最新的appcompat-v7
.
Make sure you have the latest appcompat-v7
in your app's build.gradle
.
例如:应用程序build.gradle
中的compile 'com.android.support:appcompat-v7:25.0.0'
.
这篇关于api< 21的可绘制着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文