相比于previous版本有什么新功能可绘制着色Android中大号开发preVIEW? [英] What is new in Drawable Tinting in Android L Developer Preview compared to previous version?

查看:121
本文介绍了相比于previous版本有什么新功能可绘制着色Android中大号开发preVIEW?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的新的Andr​​oid大号preVIEW现在处理上绘制着色的概念。

I am working of new Android L preview and now dealing with tinting concept on drawable.

我想知道是否有关于Android中大号开发preVIEW绘制着色任何新的东西。

I want to know if there is anything new regarding drawable tinting in Android L Developer Preview.

我读这本文档它说:

Android的大号开发preVIEW,可以定义位图或   九补丁阿尔法口罩和色调他们使用一种颜色的资源或   一个主题属性,它解析为一个颜色资源(例如,   安卓?ATTR / colorPrimary )。您可以一次创建这些资产,   它们的颜色自动匹配你的主题。

The Android L Developer Preview enables you to define bitmaps or nine-patches as alpha masks and to tint them using a color resource or a theme attribute that resolves to a color resource (for example, ?android:attr/colorPrimary). You can create these assets only once and color them automatically to match your theme.

但我不明白它是如何从previous版本不同。我知道如何使用 Col​​orFilter PorterDuffColorFilter 申请色调图像。任何有关这种帮助将AP preciated。

But I didn't understand how it is different from previous version. I know how to use ColorFilter or PorterDuffColorFilter to apply tint on image. Any help regarding this will be appreciated.

推荐答案

开始在L,可以在XML中指定的色调。这些可以引用主题属性(如图所示),彩色状态列表,颜色资源,或显式六角彩色codeS。默认情况下,色彩模式为SRC_IN,但可以使用其他的Andr​​ ?? oid设置的东西:tintMode属性

Starting in L, you can specify tints in XML. These can reference theme attributes (as shown), color state lists, color resources, or explicit hex color codes. By default, the tint mode is SRC_IN, but it can be set to something else using the android:tintMode attribute.

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/my_icon"
    android:tint="?android:attr/colorControlNormal" />

默认控制所有采用Android:ATTR / colorControlNormal为正常状态(例如,一个选中的复选框)和android:ATTR / colorControlActivated(映射到Android:ATTR / colorAccent默认情况下)为他们的激活状态(如选中的复选框)。

The default controls all use ?android:attr/colorControlNormal for their normal state (e.g. an unchecked check box) and ?android:attr/colorControlActivated (which maps to ?android:attr/colorAccent by default) for their activated state (e.g. a checked check box).

您可以使用这些属性在自己的应用程序可绘制继承默认框架的颜色,也可以重新定义它们更改默认或激活控件的颜色。您也可以参考特定属性以您的应用程序(如图所示)。

You can use these attributes in your own app drawables to inherit the default framework colors, or you can redefine them to change the default or activated control colors. You can also reference attributes specific to your app (as shown).

<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/my_icon"
    android:tint="?attr/myThemeAttribute" />

这篇关于相比于previous版本有什么新功能可绘制着色Android中大号开发preVIEW?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆