Edittext inheritance relationship: View --> textview --> edittext.
Edittext has many attributes. Here we will introduce several attributes:
Android: layout_gravity = "center_vertical"
Set the display position of the control: Top by default, which is displayed in the center and bottom.
Android: hint = "enter a number! "
Set the prompt information displayed on the space
Android: Numeric = "integer"
Only integers can be entered. If decimal is used, decimal is used.
Android: singleline = "true"
Set single-line Input. Once set to true, the text will not wrap automatically.
Android: Password = "true"
Set only passwords
Android: textcolor = "# ff8c00"
Font color
Android: textstyle = "bold"
Font, bold, italic, bolditalic
Android: textsize = "20dip"
Size
Android: Capitalize = "characters"
Uppercase/lowercase letters
Android: textalign = "center"
Edittext does not have this attribute, but textview has, center
Android: textcolorhighlight = "# cccccc"
The background color of the selected text. The default color is blue.
Android: textcolorhint = "# FFFF00"
Set the text color of the prompt information. The default color is gray.
Android: textscalex = "1.5"
Control the spacing between words
Android: Typeface = "monospace"
Font, normal, SANS, Serif, monospace
Android: Background = "@ null"
Space background. This field does not exist. It is transparent.
Android: layout_weight = "1"
Weight: controls the status between controls. It is useful when the control controls are displayed.
Android: textappearance = "? Android: ATTR/textappearancelargeinverse"
Edittext always does not pop up the software keyboard
1. The edittext keyboard is not displayed by default.
Method 1:
In androidmainfest. XML, select the activity and set the windowsoftinputmode attribute to adjustunspecified | statehidden.
Example: <activity Android: Name = ". Main"
Android: Label = "@ string/app_name"
Android: windowsoftinputmode = "adjustunspecified | statehidden"
Android: configchanges = "orientation | keyboardhidden">
<Intent-filter>
<Action Android: Name = "android. Intent. Action. Main"/>
<Category Android: Name = "android. Intent. Category. launcher"/>
</Intent-filter>
</Activity>
Method 2:
Defocus edittext. Use the clearfocus method of edittext.
For example, edittext edit = (edittext) findviewbyid (R. Id. Edit );
Edit. clearfocus ();
Method 3:
Force hide Android Input Method window
For example, edittext edit = (edittext) findviewbyid (R. Id. Edit );
Inputmethodmanager Imm = (inputmethodmanager) getsystemservice (context. input_method_service );
Imm. hidesoftinputfromwindow (edit. getwindowtoken (), 0 );
2. edittext always does not bring up the software keyboard
Example: edittext edit = (edittext) findviewbyid (R. Id. Edit );
Edit. setinputtype (inputtype. type_null );