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 )!