android studio创建android项目(4)——EditText密码输入框的使用

1、项目需求

  1. 本项目是一个安卓项目,启动页面有一个输入框。输入框的属性如下:
    (1)宽高:包裹内容即可
    (2)密码输入框
    (3)文字提示为:请输入密码(不超过5个字符);提示文字颜色:colorPrimary;
    (4)输入字符不超过5个

2、项目分析

  1. 考察EditText属性:
    (1)密码输入框 inputType为textPassword
    (2)提示文字 hint ,textColorhint
    (3)最多字符数 maxLength

3、布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.gui.eidttextset.MainActivity">

    <EditText
        android:id="@+id/password"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="textPassword"

        android:hint="@string/password_hint"
        android:textColorHint="@color/colorPrimary"

        android:maxLength="5"
        />
</LinearLayout>

4、运行结果

apk下载链接:https://pan.baidu.com/s/1IsI-AFx1SXQf5U3dHPR8TA
提取码:os2m

运行结果:
启动页:

输入字符以点显示,并且最多只能输入5个字符

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章