Android5.X对图形操作上有更多的功能。下面来看看Tinting(着色)

 

           Tinting的使用非常简单,几乎 没什么好说的,只要在xml中配置好tint和tintMode即可。直接看实际例子吧。

修改activity_main.xml代码如下:

 

 

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 3     xmlns:tools="http://schemas.android.com/tools"
 4     android:layout_width="match_parent"
 5     android:layout_height="match_parent"
 6     android:orientation="vertical">
 7 
 8     <ImageView
 9         android:layout_width="wrap_content"
10         android:layout_height="wrap_content"
11         android:src="@mipmap/ic_launcher"/>
12     <ImageView
13         android:layout_width="wrap_content"
14         android:layout_height="wrap_content"
15         android:src="@mipmap/ic_launcher"
16         android:tint="@android:color/holo_blue_bright"/>
17     <ImageView
18         android:layout_width="wrap_content"
19         android:layout_height="wrap_content"
20         android:src="@mipmap/ic_launcher"
21         android:tint="@android:color/holo_blue_bright"
22         android:tintMode="add"/>
23     <ImageView
24         android:layout_width="wrap_content"
25         android:layout_height="wrap_content"
26         android:src="@mipmap/ic_launcher"
27         android:tint="@android:color/holo_blue_bright"
28         android:tintMode="multiply"/>
29 
30     <ImageView
31         android:layout_width="wrap_content"
32         android:layout_height="wrap_content"
33         android:src="@mipmap/ic_launcher"
34         android:tint="@android:color/holo_blue_bright"
35         android:tintMode="screen"/>
36 
37     <ImageView
38         android:layout_width="wrap_content"
39         android:layout_height="wrap_content"
40         android:src="@mipmap/ic_launcher"
41         android:tint="@android:color/holo_blue_bright"
42         android:tintMode="src_atop"/>
43 
44     <ImageView
45         android:layout_width="wrap_content"
46         android:layout_height="wrap_content"
47         android:src="@mipmap/ic_launcher"
48         android:tint="@android:color/holo_blue_bright"
49         android:tintMode="src_over"/>
50 
51     <ImageView
52         android:layout_width="wrap_content"
53         android:layout_height="wrap_content"
54         android:src="@mipmap/ic_launcher"
55         android:tint="@android:color/holo_blue_bright"
56         android:tintMode="src_in"/>
57 </LinearLayout>

 

 

 

         就是将系统的一个亮蓝色用来给图片着色,黄块标注出来的代码就是不同的着色模式。我们看看都是啥样子的效果:

 

    好像这几种模式也没有显著不同啊。最终出来的效果如上。

 

posted on 2015-11-28 15:21  fuly  阅读(890)  评论(0编辑  收藏  举报