EditText的学习和使用

来源:互联网 发布:淘宝客怎么赚钱? 编辑:程序博客网 时间:2024/05/18 00:28

1.什么是EditText?

          可以输入东西的一个框框,它是TextView的一个子类。

         在main.xml中布局:

        <EditText
               android:layout_width="fill_parent"
              android:layout_height="wrap_content"/>

2.如何不让光标在EditView中聚焦,也就是光标闪??

         简单方法:

       <EditText
               android:layout_width="0dp"
               android:layout_height="0dp"/>
       <EditText
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"/>

3.限制输入字符数量

        android:maxLenth="10"

4.多行文本框

         android:singleLine="false"

5.设置提示信息

        android:hint="我是EditText"

6.EditText中显示图片

        android:drawbleLeft="@drawable/title"

7.设置圆角

        在res中的drawable文件中创建shape.xml,内容如下:

       <?xml version="1.0" encoding="UTF-8"?>
       <shape xmlns:android="http://schemas.android.com/apk/res/android"
             android:shape="rectangle">
       <!-- 填充的颜色 -->
       <solid android:color="#FFFFFF"/>
       <!-- 设置矩形的四个角为弧形 -->
       <!-- android:randius="7dip" -->
       <corners android:radius="7dip"/>
        </shape>

       在main.xml文件中:

        android:background="@drawable/shape"

原创粉丝点击