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

对应若水老师的第五课

一,设置一个输入框

添加控件:

<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属性详解

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

时间: 2024-08-10 21:25:34

android学习笔记(2)EditText控件的学习的相关文章

android学习笔记(3)Button控件的学习

对应若水老师的第六课 一,加入一个button并用外部类绑定事件 //XML文件: <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:text="扣子1&qu

Android开发中给EditText控件添加TextWatcher监听实现对输入字数的限制

做这个功能是因为开发项目的时候,由于后台接口的一些参数的值的长度有要求,不能超过多少个字符,所以在编辑框中输入的字符是要有限制的. 下面就来看一下demo的实现过程: 首先,在xml控件中放置一个EditText控件,然后初始化该控件并对该控件添加文本监听.xml自己简单的设计一下,代码较为简单,直接上代码: package com.example.edittext; import android.app.Activity; import android.os.Bundle; import an

Android开发笔记3之控件

一:编辑框 在res文件夹下的layout的文件夹的xml文件 这样在xml中我们就声明了两个控件,一个EditText和一个TextView <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_paren

Android学习笔记:常用控件 RadioGroup和CheckBox

RadioGroup和CheckBox是android的常用控件,本文自做简单介绍和学习笔记,所以所用的控件样式选用android默认的样式. 先看下代码实现的效果图 图中,上面两个(male和female)为一个RadioGroup中的两个RadioButton,下面三个为CheckBox. 一个RadioGroup里面的内容只可单选,CheckBox可多选. 接下来是代码部分 布局文件代码activity_main.xml : <LinearLayout xmlns:android="

Android开发学习笔记-自定义组合控件的过程

自定义组合控件的过程 1.自定义一个View 一般来说,继承相对布局,或者线性布局 ViewGroup:2.实现父类的构造方法.一般来说,需要在构造方法里初始化自定义的布局文件:3.根据一些需要或者需求,定义一些API方法: ----------------------------------4.根据需要,自定义控件的属性,可以参照TextView属性: 5.自定义命名空间,例如: xmlns:itheima="http://schemas.android.com/apk/res/<包名&

Android开发学习笔记-自定义组合控件

为了能让代码能够更多的复用,故使用组合控件.下面是我正在写的项目中用到的方法. 1.先写要组合的一些需要的控件,将其封装到一个布局xml布局文件中. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="

【ExtAspNet学习笔记】ExtAspNet控件库中常见问题

1.在Grid控件中添加CheckBoxField控件,选择一行时,如何获取选择的CheckBoxField所对应记录的唯一标识值? ●解决方案: 在前台Grid控件中, 添加“<ext:CheckBoxField ColumnId="myCheckBoxField" Width="60px" RenderAsStaticField="false"  DataField="MyCheckBox" CommandName=

PyQt5学习笔记04----Qt Designer控件的通用属性

在Qt Designer中的右边为我们提供了窗体.控件.布局的属性编辑功能. 比较常用的有: objectName 控件对象名称 例:quitButton= QtWidgets.QPushButton() 等号前面的那个名字 geometry 相对坐标系 sizePolicy 控件大小策略 minimumSize最小宽度.高度 maximumSize最大宽度.高度  如果想让窗体或控件固定大小,可以将mini和max这两个属性设置成一样的数值 font 字体 cursor 光标 windowTi

Framework7新版学习笔记之 开关控件

一:开关控件 新版F7增加了开关控件,在界面中提供一个开关按钮,点击它进行 打开/关闭. 二:定义开关控件并自动初始化 <label class="toggle color-xx toggle-init"> <input type="checkbox"> <span class="toggle-icon"></span> </label> 三:在js中获取开关值 var toggle =