一,linearlayout

线性布局,布局文件里设置多个linearlayout来达到总体线性布局的风格.

android:gravity="right"对齐方式,居右对齐,gravity是重心的意思

经常使用參数:center(居中)。bottom(下)。top(上)。right(右),left(左)



二,android:layout_weight

给控件分配可权值,不分配默觉得0

权值为0的控件按原来的方式给他布局;分配了权值的控件,在除去权值为0的控件之外的区域按权值布局,

比如:布局中有2个控件,一个android:layout_weight="2",还有一个android:layout_weight="1"则整个屏幕内三分之二被第一个控件占领,剩下的三分之中的一个被第二个控件占领.

样例:实现如图布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <LinearLayout
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> <!-- 水平布局 -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff0000"
android:layout_weight="1">
</EditText> <EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00ff00" >
</EditText>
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#0000ff">
</EditText>
</LinearLayout> <!-- 垂直布局 -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_gravity="right">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#2F2F4F">
</EditText>
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#B87333">
</EditText>
</LinearLayout> </LinearLayout> </RelativeLayout>

最新文章

  1. [LeetCode] Closest Binary Search Tree Value II 最近的二分搜索树的值之二
  2. 【java IO File】统计项目代码总共多少行
  3. SWING
  4. Mysql-学习笔记(==》权限管理 十 三)
  5. python03函数、递归
  6. 用户编辑新建_AngularJS实现
  7. phpmyadmin导入大sql文件失败解决办法
  8. 249. Group Shifted Strings
  9. SR4000自带软件修改(二)
  10. QTP自传之测试报告
  11. 深入理解计算机系统_3e 第二章家庭作业答案
  12. Linux的eth0,eth1,eth2,lo详解
  13. LayaAir疑难杂症之三:1.7版本click()、execCommand(&#39;copy&#39;)函数不生效
  14. 教你使用HTML5原生对话框元素,轻松创建模态框组件
  15. 微信小程序 页面跳转navigator与传递参数
  16. java.lang.NoClassDefFoundError错误
  17. 【转】MEF程序设计指南五:迟延(Lazy)加载导出部件(Export Part)与元数据(Metadata)
  18. 【学习小记】KD-Tree
  19. Django自定制分页功能
  20. Easyui tree方法扩展getImperfectCheck

热门文章

  1. pytest七:assert
  2. js中常见的数组排序算法-冒泡排序和选择排序
  3. 基于TCPCopy的仿真压测方案
  4. Nginx部署多个网站
  5. ERP退货系统管理(四十五)
  6. Ext.js中自己扩展的EasyGrid
  7. Flink(一)Flink的入门简介
  8. bzoj2654
  9. MT4编程初级手册
  10. BZOJ1787 [Ahoi2008]Meet 紧急集合 LCA