码迷,mamicode.com
首页 > 移动开发 > 详细

android学习笔记(2)EditText控件的学习

时间:2015-08-07 11:13:05      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:java   edittext   android开发   

对应若水老师的第五课


一,设置一个输入框
添加控件:

<EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="52dp"    <!--本控件顶部距离上一个控件的距离-->
        /> 

二,消除输入框的聚焦
方法一:
<EditText
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="52dp"
        />   
<EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="52dp"
        />
方法二:
<EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="52dp"
      
        >

    <requestFocus />

三,限制输入内容与长度
        android:maxLength="3"
        android:inputType="number"

四,设置提示信息
	android:hint="输入三个数字"

五,在输入框中加入图片
	在drawable-mdpi放入图片tubiao.jpg
	android:drawableLeft="@drawable/tubiao"

六,将输入框变圆角

	在drawable-mdpi中建立文件shape.xml,内容为:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid
        android:color="#e2e2e2" >
    </solid>

    <corners
        android:radius="7dp"        <!--设置弧度-->
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp" >
    </corners>

</shape>

Eclipse中的快捷键

Android layout布局属性、标签属性总结大全


Android开发之EditText属性详解


版权声明:本文为博主原创文章,未经博主允许不得转载。

android学习笔记(2)EditText控件的学习

标签:java   edittext   android开发   

原文地址:http://blog.csdn.net/sac761/article/details/47334921

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!