Android edittext User Guide

Source: Internet
Author: User

Edittext attributes

Edittext inheritance relationship: View --> textview --> edittext.
Edittext has many attributes.
Items:
Android: layout_gravity = "center_vertical"
Set the display position of the control: Default
Top, center shown here, 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
Set only passwords
Android: textcolor = "# ff8c00"
Font color
Android: textstyle = "bold"
Revenue collection
Font, bold, italic, bolditalic
Android: textsize = "20dip"
Large
Small
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"
Configuration Overview
The color of the text displayed in the information. The default value 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 to control
Status, which is useful when the control is 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
Which activity is selected in androidmainfest. XML and the windowsoftinputmode attribute is
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> hair style 123
</Activity>
Method 2:
Let
Edittext loses focus and uses the clearfocus method of edittext.
Example: edittext
Edit = (edittext) findviewbyid (R. Id. Edit );
Edit. clearfocus ();
Fang
Method 3:
Force hide Android Input Method window
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 );

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.