码迷,mamicode.com
首页 > 其他好文 > 详细

3.21-登录界面

时间:2016-03-21 22:54:36      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:

1、背单词

title-标题

finish-完成

format-格式化

layout-布局

Window-窗口

graphical-图形化

EditText-编辑文本

LinearLayout-线性布局

vertical-竖直

horizontal-横向

width-宽

height-高

 

布局:就是一个容器。

LinearLayout:具有两个方向,一个是横向,另一个是纵向。

标签:<这俩个尖括号内的就是标签>,标签可以有很多属性;如果不指定特定的属性值,系统会用默认值;不同标签可能有不同属性;标签有开始标签<标签名>和结束标签</标签名>,或者是<标签名/>。

TextView:文本标签

EditText:编辑文本标签

Button:按钮标签

 

属性:大多数标签都要求有android:layout_width和android:layout_height属性。

android:layout_width:控件的宽

android:layout_height:控件的高

android:text:控件显示的文本

android:layout_gravity:定义子控件在父控件中的位置

android:gravity:定义控件中的内容在控件中的位置

android:layout_margin:控件离其他控件(包括父控件和兄弟控件)的统一距离。

android:layout_marginLeft:控件的左外边距

android:layout_marginRight:控件的右外边距

android:layout_marginTop:控件的上外边距

android:layout_marginBottom:控件的下外边距

android:inputType:是EditText标签中的属性,用于控制输入内容的类型,比如密码的属性值是textPassword。

android:hint:是EditText标签中的属性,用于提示用户输入

android:textColor:定义字体颜色,属性值为三原色的十六进制值。格式有#rgb或者#rrggbb等。r指red(红),g指green(绿),b指blue(蓝)。ffffff或fff是白,0000ff或00f是蓝,000000是或000黑,eeeeee或eee是灰。

android:background:定义控件的背景,可以为图片,也可以为颜色。

如:下面两种方式效果相同

技术分享
 1 <TextView
 2     android:layout_width="wrap_content"
 3     android:layout_height="wrap_content"
 4     android:text="司机登录" 
 5     android:layout_gravity="center"
 6     />
 7 
 8  <TextView
 9     android:layout_width="match_parent"
10     android:layout_height="wrap_content"
11     android:text="司机登录" 
12     android:gravity="center"
13     />
View Code


xml文件注释:<!--要注释的内容--> ,快捷键是Shift+Ctrl+/。

 

代码:

技术分享
 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     android:layout_width="fill_parent"
 3     android:layout_height="fill_parent"
 4     android:orientation="vertical" >
 5 
 6     <TextView
 7         android:layout_width="wrap_content"
 8         android:layout_height="wrap_content"
 9         android:layout_gravity="center"
10         android:text="司机登录" />
11 
12     <EditText
13         android:layout_width="match_parent"
14         android:layout_height="wrap_content"
15         android:layout_marginLeft="20dp"
16         android:layout_marginRight="20dp"
17         android:layout_marginTop="20dp"
18         android:background="#fff"
19         android:hint="手机号码" />
20 
21     <EditText
22         android:layout_width="match_parent"
23         android:layout_height="wrap_content"
24         android:layout_marginLeft="20dp"
25         android:layout_marginRight="20dp"
26         android:layout_marginTop="20dp"
27         android:background="#fff"
28         android:hint="密码"
29         android:inputType="textPassword" />
30 
31     <Button
32         android:layout_width="match_parent"
33         android:layout_height="wrap_content"
34         android:layout_marginLeft="20dp"
35         android:layout_marginRight="20dp"
36         android:layout_marginTop="20dp"
37         android:background="#00f"
38         android:text="登录"
39         android:textColor="#ffffff" />
40 
41 </LinearLayout>
View Code

 

3.21-登录界面

标签:

原文地址:http://www.cnblogs.com/zqc2576080287/p/5304069.html

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