登陆界面 LinearLayout的属性的用法
来源:互联网 发布:百世汇通软件 编辑:程序博客网 时间:2024/06/07 14:59
通过设计登录界面的实例来了解LinearLayout一些属性的用法
要点:
android:orientation="vertical"垂直线性布局,"horizontal"水平线性布局
android:gravity="top"(buttom、left、right、center_vertical、fill_vertical、center_horizontal、fill_horizontal、center、fill、clip_vertical、clip_horizontal)控制布局中控件的对齐方式。如果是没有子控件的控件设置此属性,表示其内容的对齐方式,比如说TextView里面文字的对齐方式;若是有子控件的控件设置此属性,则表示其子控件的对齐方式,gravity如果需要设置多个属性值,需要使用“|”进行组合
android:gravity 与 android:layout_gravity的区别
android:gravity是指定本元素的子元素相对它的对齐方式。
android:layout_gravity是指定本元素相对它的父元素的对齐方式。
<?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:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="400dp" android:orientation="vertical" > <!-- 标题 --> <!-- android:gravity="center" 因为有子控件,所以作用是设置子控件在本控件中的位置 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="3" android:gravity="center" android:orientation="vertical" ><!-- android:gravity="center" 因为没有子控件,所以作用是设置文字在TextView中的位置 --> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:text="淘宝客户端" android:textSize="25sp"/> </LinearLayout> <!-- 内容 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:orientation="horizontal" android:padding="5dp" ><!-- layout_weight="3"使TextView占宽度的1/4 layout_weight="1"使EditText占比重的3/4--> <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="3" android:gravity="center" android:text="账 号" android:textSize="18sp" /> <EditText android:id="@+id/zhanghao" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:hint="输入账号名" android:textSize="18sp" /> </LinearLayout><!-- android:padding="5dp" 使子控件距离边缘5dp --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:orientation="horizontal" android:padding="5dp" > <TextView android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="3" android:gravity="center" android:text="密 码" android:textSize="18sp" /> <EditText android:id="@+id/zhanghao" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:hint="输入密码" android:textSize="18sp" /> </LinearLayout> <!-- 按钮 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="3" android:gravity="center" android:orientation="horizontal" > <Button android:id="@+id/login" android:layout_width="120dp" android:layout_height="wrap_content" android:text="登录" /> <Button android:id="@+id/login" android:layout_width="120dp" android:layout_height="wrap_content" android:text="注册" /> </LinearLayout> </LinearLayout></LinearLayout>
0 0
- 登陆界面 LinearLayout的属性的用法
- 用LinearLayout和RelativeLayout分别实现简单的登陆界面
- LinearLayout的Divider属性
- LinearLayout的layout_weight属性
- Android 之LinearLayout的属性
- LinearLayout layout_weight属性的妙用
- android linearlayout 的gravity属性
- LinearLayout布局的layout_weight属性
- RelativeLayout和LinearLayout的属性
- 浅析LinearLayout的weight属性
- LinearLayout的weight(权重属性)
- Linearlayout的android:divider属性
- 安卓 LinearLayout的用法
- Linearlayout下的layout_gravity用法
- 登陆界面的判断
- 登陆界面的设计
- 登陆界面的完善
- 登陆界面的搭建
- HDU 1166 敌兵布阵 (线段树)
- HDOJ 题目1564 play a game(博弈)
- windows下Android源码的分模块下载
- Minimum Depth of Binary Tree(LeetCode)
- git学习 - 忽略版本控制文件
- 登陆界面 LinearLayout的属性的用法
- 我之见--java进程,线程
- VS自定义代码折叠的位置
- 中期报告:多平台网络探测器
- poj 1088 滑雪 【记忆化搜索】+【DFS】
- malloc/free 的使用要点 以及 new/delete 的使用要点
- XE6 安卓电量检测
- uva 705 Slash Maze
- poj3692二分图最大团