Android-TextView of common controls

Source: Internet
Author: User
Tags xml attribute

Android-TextView of common controls
Here we can know that TextView is a subclass of View. It has a subclass of buttons and EditText. Next we will learn about the xml Attribute android of TextView: EMS sets TextView width to N characters. android: maxems sets TextView width to N characters at most. When used together with EMS, the options android: maxLength are overwritten to limit the number of input characters android: lines sets the number of lines of text android: maxLines sets the maximum number of lines of text display. android: lineSpacingExtra sets the row spacing android: lineSpacingMultiplier sets the row spacing multiple android: password displays text in the form of a password android: numeric if set, a digital input method (Edittext attribute) android is displayed: set phoneNumber to the phone number input method android: singleLine to set the display of a single line android: textAppearance to set the text appearance. Android: textColor set text color android: textColorHighlight selected text background color android: textColorHint set text color of the prompt information, the default is gray. Use the color of the android: textColorLink text link with the hint. android: textScaleX sets the interval between texts. android: textSize sets the text size. The recommended measurement unit is "sp". android: textStyle sets the font android: typeface sets the text font android: drawableTop sets the image above the text android: drawablePadding sets the spacing attribute of the text and the image. How can this attribute be used? The properties of the control are used in the xml file. Next we open the activity_main.xml file in layout. Switching to the code mode does not require dragging controls for real android development !!! The root node is a viewgroup control. viewgroup indicates that this control can contain many controls, such as our layout control, layout controls can contain a lot of control copy code 1 <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" 2 xmlns: tools = "http://schemas.android.com/tools" 3 android: layout_width = "match_parent" 4 android: layout_height = "match_parent"> 5 <! -- Enter TextView in the middle area --> 6 7 </LinearLayout> to copy the Code. In the middle area, enter <TextView android: layout_width = "match_parent" android: layout_height = "wrap_content" android: text = "@ string/app_name" android: textColor = "#8A2BE2" android: textSize = "30sp"/> note: In the layout file, all controls must be added with android: layout_width and android: layout_height attributes! It indicates the width and height of the control on the screen. Generally, there are three values: 1. match_parent: The component is displayed as big as its parent component. wrap_content: the size of the component content. fill_parent: it is the same as match_parent. After 2.2, match_parent will be used to write the TextView. After that, the purple text is displayed and the font size is 30sp. The other attributes of TextView will be handed over to you for trial.

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.