跟我学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点击动态 ...
随机推荐
- Linux&shell 之Shell命令进阶
写在前面:案例.常用.归类.解释说明.(By Jim) 监控程序a.进程查看ps -ef(-e表示系统上运行的所有进程,-f用于扩展输出一些有用的信息列.)ps -efH(-H参数可以将进程组织为分层 ...
- -_-#【jsonp】cache
Cache jQuery’s JSONP Calls <script src="http://upcdn.b0.upaiyun.com/libs/jquery/jquery-2.0.3 ...
- 数学(线性规划):UVAoj 10498 Happiness
Problem GHappiness! Input: standard inputOutput: standard outputTime Limit: 3 seconds Prof. Kaykobad ...
- 数据结构(线段树):BZOJ 3126: [Usaco2013 Open]Photo
3126: [Usaco2013 Open]Photo Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 222 Solved: 116 Descrip ...
- 数学概念——F 概率(经典问题)birthday paradox
F - 概率(经典问题) Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit S ...
- Change ugly fonts in Firefox (KDE)
When you use KDE the fonts in Firefox are ugly. This is the fix: Open with Kate: /home/yourusername/ ...
- Chrome启动参数的配置问题的补充
一.当Chrome浏览器不支持本地AJAX请求时,会出现AJAX跨域问题,这时候我们就要配置相应的启动参数使得浏览器可以访问本地文件: 配置参数为:--allow-file-access-from-f ...
- 路由器刷机常见第三方固件及管理前端种类(OpenWrt、Tomato、DD-Wrt)
目前路由器折腾刷机,除了采用各品牌的原厂固件外,第三方路由器固件,基本就是:Tomato.DD-WRT.OpenWRT三种. 基本上所有第三方路由器固件的架构上可分为前端(Frontend)和后端(B ...
- 用过coreData或者sqlite吗?读写是分线程的吗?
文/natewang(简书作者)原文链接:http://www.jianshu.com/p/cb8dc61b12fa著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”. 如果不是要求特别高, ...
- springboot 配置文件 .properties和.yml的写法区别
例如 : redis配置的properties或yml文件,如下: spring.redis.cluster.nodes[]= spring.redis.cluster.nodes[]= 或 s ...