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

本文介绍了 Android 开发中 EditText 控件的使用方法,包括如何设置输入框、消除聚焦、限制输入内容与长度、设置提示信息、在输入框中加入图片以及如何使输入框呈现圆角效果等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



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

<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里面EditTex多行输入及输入置顶问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值