属性

  • 设置最大显示行数 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);            }        });

  • 编辑带圆角和描边的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. android 开发问题集,android问题总结,android错误解决收集
  2. EditText的属性
  3. Android(安卓)requires compiler compliance level 5.0 or 6.0.
  4. LinearLayout 内部控件居中
  5. android点滴
  6. Android添加垂直滚动ScrollView
  7. android点滴4
  8. android 日期时间格式转换;软键盘显示消失;获取系统title
  9. android中之断点续传

随机推荐

  1. Android(安卓)Path的使用
  2. Android重启应用程序代码
  3. android 杀进程方法
  4. android本地音乐播放(一)
  5. Android(安卓)发送无序广播
  6. android 工程源码下编译 Android.mk写法
  7. Android中HandlerThread的使用
  8. 15、android 常用文件路径备忘
  9. android 安装配置
  10. android 自定义view 不执行 ondraw的解决