android studio引入了一个很牛逼的功能
可以直接修改图片文件的颜色!
原本白色的搜索图标
在drawable下新建一个search_icon_green.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"android:src="@drawable/ic_search"
android:tint="@color/green"
android:tintMode="src_over"
>
</bitmap>
这样之后,图片的颜色就直接变成了绿色的啦
不过不要太卡开心。需要API21
Attribute tintMode
is only used in API level 21 and higher (current min is 16) less... (Ctrl+F1)
This check finds attributes set in XML files that were introduced in a version newer than the oldest version targeted by your application (with the the minSdkVersion
attribute).
This is not an error; the application will simply ignore the attribute. However, if the attribute is important to the appearance of functionality of your application, you should consider finding an alternative way to achieve the same result with only available attributes, and then you can optionally create a copy of the layout in a layout-vNN folder which will be used on API NN or higher where you can take advantage of the newer attribute.
Note: This check does not only apply to attributes. For example, some tags can be unused too, such as the new <tag>
element in layouts introduced in API 21.