跟我学android-常用控件之EditText
EditText 是TextView的直接子类,它与TextView的区别在于,EditText可以接受用户输入。
下面通过一个实例来说明EditText的用法
实例:sina 微博的登录界面(注意,由于 我们还没有接触 按钮 和图片的控件,所以 按钮盒图片的地方 我们使用TextView 做)
首先看sina 微博登录页面的效果图
由于该截图是我从iphone上截取下来的,sina 微博android版本的背景不是这张,所以 我更换了背景图
代码如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/login_wallpaper1"
android:orientation="vertical" > <!-- 用户头像 --> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/login_profile_default" />
<!-- 用户名和密码输入框,使用嵌套布局 --> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="@drawable/fast_select_merchant_input_bg"
android:orientation="vertical" > <EditText
android:id="@+id/et_user"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:drawableLeft="@drawable/login_user"
android:drawablePadding="15dp"
android:hint="邮箱/手机号"
android:padding="10dp" />
<!-- 分割线 --> <View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray" /> <EditText
android:id="@+id/et_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null" android:drawableLeft="@drawable/login_key"
android:drawablePadding="15dp"
android:hint="请输入密码"
android:inputType="textPassword"
android:padding="10dp" />
</LinearLayout>
<!-- 模拟登录按钮 --> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#006400"
android:gravity="center"
android:padding="10dp"
android:text="登录"
android:textColor="#F8F8FF"
android:textSize="30sp" /> </LinearLayout>
布局是可以嵌套布局的,在这个登录页面中 我的输入框部分采取的是 嵌套一个 线性布局。
大家可以预览一下效果。
跟我学android-常用控件之EditText的更多相关文章
- Android常用控件及对应Robotium API
最近发现Android控件不熟悉,看Robotium的API都费劲. 常用Android控件: 控件类型 描述 相关类 Button 按钮,可以被用户按下或点击,以执行⼀个动作 Button Text ...
- 常用的基本控件 android常用控件
1.TextView:(文本框):不能编辑 android:textColor="@color/tv_show_color" 字体颜色 android:textSize ...
- Android常用控件
Android 中使用各种控件(View) DatePicker - 日期选择控件 TimePicker - 时间选择控件 ToggleButton - 双状态按钮控件 EditText - 可编辑 ...
- Android常用控件之GridView使用BaseAdapter
我们可以为GridView添加自定义的Adapter,首先看下用自定义Adapter的显示效果 在布局文件main.xml文件中定义一个GridView控件 <RelativeLayout xm ...
- 一步一步学android之控件篇——ScrollView
一个手机的屏幕大小是有限的,那么我要显示的东西显示不下怎么办?这就会使用到ScrollView来进行滚动显示,他的定义如下: 可以看到ScrollView是继承于FrameLayout的,所以Scro ...
- Android常用控件之RatingBar的使用
RatingBar控件比较常见就是用来做评分控件,先上图看看什么是RatingBar 在布局文件中声明 <?xml version="1.0" encoding=" ...
- android常用控件的使用方法
引言 xml很强大 TextView <TextView android:id="@+id/text_view" android:layout_width="mat ...
- Android常用控件之FragmentTabHost的使用
最近在学TabHost时发现TabActivity在API level 13以后不用了,所以就去寻找它的替换类,找到FragmentActivity,可以把每个Fragment作为子tab添加到Fra ...
- 一步一步学android之控件篇——ListView基本使用
ListView组件在应用程序中可以说是不可或缺的一部分,ListView主要是显示列表数据,同时可以滚动查看,这篇博客主要是对ListView的基本用法进行说明,后面会依次对ListView点击动态 ...
随机推荐
- java学习面向对象之static内存图解
上一节当中描述了static的用法,以及成员变量和静态变量的区别.但是static除了可以修饰成员变量使之成为静态变量外,他还可以同时修饰函数,使之成为静态函数,我们来看一个例子: class Sta ...
- AlgorithmsI Exercises: UnionFind
Question1 Give the id[] array that results from the following sequence of 6 unionoperations on a set ...
- (转载)在Linux下删除文件行末尾的^M符号方法
(转载)http://www.xinfengit.com/200907/1433646.html 由于DOS下的编辑器和linux(linux教程 linux培训 )编辑器对文件行末的回车符处理不一致 ...
- 数学概念——F 概率(经典问题)birthday paradox
F - 概率(经典问题) Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit S ...
- Threading Module源码概述(一)
Python的Threading模块是建立在thread module基础上的一个模块,在threading模块中,暴露着许多thread模块的属性.比如threading._get_ident实际上 ...
- Y2错题解析
数据流程图描述信息的来龙去脉和实际流程,反映信息在系统中流动.处理和存储的情况.程序结构图用来描述程序结构,一般由构成系统的要素和表达要素间关系的连线或箭头构成.因果图是一种发现问题"根本原 ...
- Struts2接收参数的几种方式
一.用Action属性 在action里定义要接收的参数,并提供相应的set和get方法. 如: public class LoginAction extends ActionSupport { pr ...
- android ContentProvider学习
1.ContentProvider提供位存储或获取数据提供了统一的接口. 2.使用ContentProvider可以在不同的应用程序之间共享数据. 3.Android为常见的一些数据提供了Conten ...
- 论C++与三国
Scott Meyers曾说过,C++语言是一个语言联邦.C++包含面向过程,面向对象,泛型编程编程思想.现在C++11有加了一堆新特性,语言联邦更为庞大. 程序员们.常常挑起语言之争,甚至连大师级人 ...
- rsyslog 报 WARNING: rsyslogd is running in compatibility mode.
[root@localhost log]# uname -a Linux localhost.localdomain 2.6.32 #1 SMP Sun Sep 20 18:58:21 PDT 2 ...