Ym--android 5.0 Study of tinting and clipping

Source: Internet
Author: User

Objective

The Android 5.0 knowledge point is finished, the next one to bring you a comprehensive example of the demo, and talk about my view of Android 5.0.

Some people will think why not every blog with a demo, I think no matter what to learn everything needs to practice, so I did not provide demo, I would like to first let everyone own to follow the steps I wrote to achieve this, in the process of implementation will encounter difficulties, and then go to find solutions, Finally, do it yourself, so that we can be impressed by what we have learned.

drawable Tinting (coloring)

Set the Android:tint property of ImageView to achieve the following effects:


Layout

    <imageview            android:layout_width= "100DP"            android:layout_height= "100DP"            android:elevation= "1dip"            android:layout_gravity= "center"            android:src= "@drawable/ic_launcher"            />    <imageview            android:layout_width= "100DP"            android:layout_height= "100DP"            android:elevation= "1dip"            android:layout_gravity= "center"            android:src= "@drawable/ic_launcher"            android:tint= "@android: color/ Holo_red_dark "            />
Not only can set tint also can set Tintmode, respectively set different mode effect is as follows:

Srceen


Multiply


Add


src_atop/ src_in/ Src_over


Clipping Views (crop view)

First we layout, set the two square TextView

    <textview            android:id= "@+id/tv_1"            android:layout_width= "100DP"            android:layout_height= "100DP"            android:elevation= "1dip"            android:layout_gravity= "center"                          />    <textview            android:id = "@+id/tv_2"            android:layout_width= "100DP"            android:layout_height= "100DP"            android:elevation= "1dip "            android:layout_gravity=" center "                         />
Then we cut them two separately into rounded squares and circles:

<span style= "White-space:pre" ></SPAN>V1 = Findviewbyid (r.id.tv_1);        V2 = Findviewbyid (r.id.tv_2);        Viewoutlineprovider Viewoutlineprovider = new Viewoutlineprovider () {            @Override public            void Getoutline (View View, Outline Outline) {                outline.setroundrect (0, 0, view.getwidth (), View.getheight (), ten);            }        };        Viewoutlineprovider viewOutlineProvider1 = new Viewoutlineprovider () {            @Override public            void Getoutline (View View, Outline Outline) {                outline.setroundrect (0, 0, view.getwidth (), View.getheight (), View.getheight ()/2);            }        };        V1.setoutlineprovider (Viewoutlineprovider);        V2.setoutlineprovider (ViewOutlineProvider1);

The effect is as follows:




Ym--android 5.0 Learning tinting and clipping

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.