EditText usage details
•
Android
This article mainly introduces some knowledge points in Android development. By reading this article, you will gain the following contents:
EditText inherits as follows:
java.lang.Object
↳ android.view.View
↳ android.widget.TextView
↳ android.widget.EditText
EditText is mainly used to input and modify text content.
It is restricted that only plain text can be entered. Examples are as follows:
<EditText
android:id="@+id/plain_text_input"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:inputType="text"/>
<!-- 自定义EditText 背景 -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/custom_edittext_background"
android:gravity="center"
android:hint="一、自定义EditText背景框"
android:padding="8dp"
android:textSize="16sp" />
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 圆角-->
<corners android:radius="5dp" />
<!--描边-->
<stroke
android:width="1dp"
android:color="@android:color/holo_blue_light" />
</shape>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:autoText="true"
android:hint="二、自动检测输入更正属性 autoText"
android:textColor="#FF6100" />
<!-- 以密文的形式显示 -->
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="三、以密文的形式显示密码"
android:password="true" />
Only Arabic numerals can be entered to realize the following:
<!-- 设置允许输入的字符 -->
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:digits="123456789.+-*/\n()"
android:hint="四、设置限制允许输入阿拉伯数字" />
EditText is often used to get the user input content, because we want to avoid the situation that the user input content is empty.
The results are as follows:
The implementation code is as follows:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码