1、項目需求
- 本項目是一個安卓項目,啓動頁面有一個輸入框。輸入框的屬性如下:
(1)寬高:包裹內容即可
(2)密碼輸入框
(3)文字提示爲:請輸入密碼(不超過5個字符);提示文字顏色:colorPrimary;
(4)輸入字符不超過5個
2、項目分析
- 考察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個字符