As one of the most common controls of android, it has the following common attributes:
Layout_width, layout_height: required properties for each control
Text: text display, INPUT attribute
TextColor: text color attribute
TextSize: Text Size
There are also some features used in some occasions
AutoLink: sets whether the text is displayed as a URL link, email, phone number, or map. The text is displayed as a clickable link.
AutoText: the spelling of the input value is automatically corrected.
DrawableBottom: Output A drawable under text.
DrawableRight: Output A drawable on the Right of text.
DrawableTop: Output A drawable on the top of the text.
Editable: Set whether to edit
Ellipsize: Set how to display the control when the text is too long
EMS: Set the width to N characters
ShadowRadius: Set the shadow radius.
ShadowColor: Specifies the color of text shadow, which must be used with shadowRadius and must be set with shadowRadius.
ShadowDx: Set the start position of the Shadow horizontal coordinate.
ShadowDy: Specifies the start position of the Shadow vertical coordinate.
There are many other attributes. These android textviews provide a lot of information. You are familiar with them and have a good grasp of some common attributes. You can check the APIs for other features.
Next, I will focus on it. When we need the TextView function of some features, but the provided api cannot meet the requirements, for example, to make a skewed Textview,
This requires customization.
Steps:
1. Write a MyTextView class to inherit the View and override the onDraw () method of the View.
2. We also need a Paint brush to help us draw TextView;
Paint p = new Paint (); p. setColor (Color. BLUE); p. setAntiAlias (true); // remove missing sertices
3. the paint brush is ready and the content is painted. At this time, TextView is displayed normally. to tilt TextView, We can tilt the canvas.
Canvas c = new Canvas (); c. save (); // save, which appears in pairs with restore. save the canvas status and do not affect c. rotate (45); // set the canvas to rotate 45 degrees c. drawPaint (p); c. restore ();
4. After the custom TextView is completed, we can reference it in Xml.
You're done. Do you want to go back and try it yourself?