[Andorid X Project Notes] TextView subtitle effect (3)

Source: Internet
Author: User
Tags drawtext


[Andorid X project notes]



You are welcome to repost, but please keep the original source of the article :)
Blog: http://www.cnblogs.com

Farmer's uncle: http://over140.cnblogs.com



1. [Andorid X Project Notes] disable the Fling function of ListView (1)

2. [Andorid X Project Notes] dynamically setting the Adapter problem of ViewPager (2)





Ii. Code


Public class TextSubView extends TextView {

Private TextPaint mPaint;

Public TextSubView (Context context, AttributeSet attrs ){
Super (context, attrs );

MPaint = new TextPaint (getPaint ());
MPaint. setStyle (TextPaint. Style. STROKE );
MPaint. setShadowLayer (2.0F, 2.0F, 2.0F, Color. RED );

@ Override
Protected void onDraw (Canvas canvas ){
Super. onDraw (canvas );

Canvas. save ();
Canvas. clipRect (0, 0, 55, getBottom ());
Canvas. drawText (getText (). toString (), 0, getBaseline (), mPaint );
Canvas. restore ();


Code Description:

The key is to set the shadowlayer shadow effect and the four lines of onDraw code. You can search for "Android clipRect" to find out the function. Do not reverse the order of clipRect and drawText.


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.