属性

  • 设置最大显示行数 android:maxLines
  • 设置默认显示的提示信息 android:hint
  • 设置文本框中的输入类型属性 android:inputType

关于密码显示的设置

  • 将输入的内容转换为*,变为不可辨认
        editText= (EditText) findViewById(R.id.editText);        button= (Button) findViewById(R.id.button_pass);        button.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                editText.setTransformationMethod(new PasswordTransformationMethod());            }        });

  • 将密码变为可见,可以看到
  • 在布局文件中要添加代码如下
android:inputType="textPassword"
  • 代码如下
        editText= (EditText) findViewById(R.id.editText);        button= (Button) findViewById(R.id.button_pass);        button.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v) {                editText.setTransformationMethod(null);            }        });

UI控件--EditText_第1张图片

  • 编辑带圆角和描边的EditText
  • 首先定义shape的xml文件
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android">    <corners android:radius="8dp"></corners>    <stroke android:color="#000000" android:width="2dp"></stroke>    <padding android:bottom="8dp" android:left="8dp" android:right="8dp" android:top="8dp"></padding></shape>
  • 然后再布局文件中进行引用
<EditText        android:id="@+id/editText_1"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="@drawable/edittext_1"        android:layout_margin="10dp"        android:hint="@string/editText1"        android:maxLines="2"        />
  • 效果图

更多相关文章

  1. EditText的属性
  2. android读写文件
  3. android笔记一 控件属性
  4. Android内核的根文件系统
  5. Android 简单的账号密码登陆界面(IO流)
  6. android获取文件目录
  7. Android代码实现APK文件的安装与卸载

随机推荐

  1. android 中隐藏EditText的下划线方法
  2. Android(安卓)AOSP源码下载编译
  3. Android(安卓)AndBox 安安卜1.3发布
  4. Android中判断网络功能是否可用
  5. Tips: compilation and creating new pro
  6. 如何在Android中使用OpenCV
  7. Android(安卓)SD卡操作
  8. Android(安卓)之读取元素中的数据
  9. Android多国语言文件夹命名
  10. [Android]Android(安卓)FTP Server