LinearLayout的一些注意事项 分类: H1_ANDROID 2013-10-26 23:01 856人阅读 评论(0) 收藏
1、orientation的默认值为horizontal,即从左向右排列。由于一般从上向下排列,所以必须指定orientation属性。
2、layout_gravity与gravity的区别:
(1)gravity指定自身所包含的子元素的对齐方式,如LinearLayout中的gravity指定了它的子元素(即5个TextView)水平居中排名,第二个TextView指定了其子元素(内容)向左对齐。
(2)layout_gravity用于指定自身在父元素中的对齐方式,并可覆盖其父元素的gravity属性。如第一个TextView指定了其自身在父元素(LinearLayou)中向右对齐,并覆盖了LinearLayout中的layout_gravity属性。
<LinearLayout 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"
android:orientation="vertical"
android:gravity="center_horizontal"
tools:context=".MainActivity" > <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:layout_gravity="right"/> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
android:text="@string/hello_world" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" /> </LinearLayout>
版权声明:本文为博主原创文章,未经博主允许不得转载。
LinearLayout的一些注意事项 分类: H1_ANDROID 2013-10-26 23:01 856人阅读 评论(0) 收藏的更多相关文章
- 【从0到1学Web前端】CSS定位问题三(相对定位,绝对定位) 分类: HTML+CSS 2015-05-29 23:01 842人阅读 评论(0) 收藏
引子: 开始的时候我想先要解决一个问题,怎么设置一个div盒子撑满整个屏幕? 看下面的html代码: <body> <div id="father-body"&g ...
- 认识C++中的临时对象temporary object 分类: C/C++ 2015-05-11 23:20 137人阅读 评论(0) 收藏
C++中临时对象又称无名对象.临时对象主要出现在如下场景. 1.建立一个没有命名的非堆(non-heap)对象,也就是无名对象时,会产生临时对象. Integer inte= Integer(5); ...
- Drainage Ditches 分类: POJ 图论 2015-07-29 15:01 7人阅读 评论(0) 收藏
Drainage Ditches Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 62016 Accepted: 23808 De ...
- pascal矩阵 分类: 数学 2015-07-31 23:01 3人阅读 评论(0) 收藏
帕斯卡矩阵 1.定义 帕斯卡矩阵:由杨辉三角形表组成的矩阵称为帕斯卡(Pascal)矩阵. 杨辉三角形表是二次项 (x+y)^n 展开后的系数随自然数 n 的增大组成的一个三角形表. 如4 ...
- MATLAB格式化输出控制 分类: 数学 2015-07-31 23:01 3人阅读 评论(0) 收藏
MATLAB格式化输出控制 format 默认格式 format short 5字长定点数 format long 15字长定点数 format short e 5字长浮点数 format long ...
- Windows7下QT5开发环境搭建 分类: QT开发 2015-03-09 23:44 65人阅读 评论(0) 收藏
Windows7下QT开法环境常见搭配方法有两种. 第一种是:QT Creator+QT SDK: 第二种是:VS+qt-vs-addin+QT SDK: 以上两种均可,所需文件见QT社区,QT下载地 ...
- short-path problem (Floyd) 分类: ACM TYPE 2014-09-01 23:58 100人阅读 评论(0) 收藏
#include <cstdio> #include <iostream> #include <cstring> using namespace std; cons ...
- short-path problem (Dijkstra) 分类: ACM TYPE 2014-09-01 23:51 111人阅读 评论(0) 收藏
#include <cstdio> #include <iostream> #include <cstring> using namespace std; cons ...
- 快速幂取模 分类: ACM TYPE 2014-08-29 22:01 95人阅读 评论(0) 收藏
#include<stdio.h> #include<stdlib.h> //快速幂算法,数论二分 long long powermod(int a,int b, int c) ...
随机推荐
- hdu 1384 Intervals (差分约束)
/* 给你 n 个区间 [Ai, Bi],要求从每一个区间中至少选出 Ci 个数出来组成一个序列 问:满足上面条件的序列的最短长度是多少? 则对于 不等式 f(b)-f(a)>=c,建立 一条 ...
- Elasticsearch5.0.1 + Kibana5.0.1 + IK 5.0.1
Elasticsearch5.0.1 + Kibana5.0.1 + IK 5.0.1安装记录 最近工作需要,开始研究ES,当前ES的最新版本为5.0.1,从之前的2.x的版本号一下升级到5.x,主要 ...
- golang sync.Mutex(2)
package main import ( "fmt" "sync" "time" ) type User struct { Name st ...
- 洛谷P3613 睡觉困难综合征(LCT)
题目: P3613 睡觉困难综合症 解题思路: LCT,主要是维护链上的多位贪心答案,推个公式:分类讨论入0/1的情况,合并就好了(公式是合并用的) 代码(我不知道之前那个为啥一直wa,改成结构体就好 ...
- windows程序生成目标平台与CLR运行执行过程
C# 编译器提供一个选项, 该选项允许指定最终生成的程序集只能运行在32位windows版本的X86机器上使用, 只能在运行64位windows的X64机器上使用, 或者只能在32为windows R ...
- 栅格数据AE
转自原文 栅格数据AE 两个星期以来一直与栅格数据打交道,对AO的栅格部分应该有了一定的理解,下面是自己的一点体会,希望高手指教:-) 1.栅格数据的存储类型 栅格数据一般可以存储为ESRI GRID ...
- 找不到或无法载入主类 org.jivesoftware.openfire.starter.ServerStarter
刚接触openfire的配置就出现了这个错误.解决方法非常easy,忘记了将openfire的源文件加入到user entries中了
- android:一个Open键引发的问题!!
1.问题简单介绍 首先描写叙述一下问题.当我们安装完APP的时候,界面会显示两个button,一个完毕键,一个Open键,点击Open键之后.进入应用.此时.我们点击HOME键.程序将会后台.然后再点 ...
- ie为什么那么垃圾(不是ie垃圾,是ie用的人太多了,很多在用低版本)
ie为什么那么垃圾(不是ie垃圾,是ie用的人太多了,很多在用低版本) 一.总结 1.我们觉得ie差的原因:我们拿老的ie和最新的其它浏览器做比较了,两者相差了很多年.比较微软几十年才发布了11个ie ...
- 81.内存模式实现cgi查询
创建全局的二级指针 char ** g_pp;//全局的二级指针 获取数据有多少行 //获取行数 int getimax() { ; FILE *pf = fopen(path, "r&qu ...