AndroidUI control series: TextView (text box)

Source: Internet
Author: User
TextView is relatively simple. it cannot be used for editing. it can only be used to display information. TextView is relatively simple. it cannot be used for editing. it can only be used to display information.

Some common XML attributes in the layout file

Android: gravity-used to set the text alignment in the control

Android: layout_gravity-compared with the parent control, it is used to set the control alignment.

Android: text-used to set control text information

Android: layout_width-used to set the width of the control

Android: layout_height-used to set the height of the control

Android: background-used to set the background color of a widget

Android: textColor-used to set the color of text in the control

Android: textSize-used to set the text font size of the control

Android: width and android: height-functions are similar to android: layout_width.

Differences:

Android: layout_width can only be set to fill_parent (fill the whole screen horizontally) or
Wrap_content (size of the horizontal filling control)

Android: width: sets the horizontal size unit of a specific control to pixels.
Example: TextView display

Main. xml layout file

   
   
    
 

String. xml file

   
       
  
   Hello World, MyTestView!
        
  
   MyTestView
    
 

MyTextView. java file

package org.loulijun.MyTestView;    import android.app.Activity;  import android.os.Bundle;    public class MyTestView extends Activity {      /** Called when the activity is first created. */      @Override      public void onCreate(Bundle savedInstanceState) {          super.onCreate(savedInstanceState);          setContentView(R.layout.main);      }  }

Running result:

The above is the content of the Android UI control series: TextView (text box). For more information, see PHP Chinese network (www.php1.cn )!

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.