android学习笔记(8)linearlayout与android:layout_weight学习
一,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>
android学习笔记(8)linearlayout与android:layout_weight学习的更多相关文章
- Flutter学习笔记(30)--Android原生与Flutter混编
如需转载,请注明出处:Flutter学习笔记(30)--Android原生与Flutter混编 这篇文章旨在学习如何在现有的Android原生项目上集成Flutter,实现Android与Flutte ...
- Hadoop源码学习笔记(3) ——初览DataNode及学习线程
Hadoop源码学习笔记(3) ——初览DataNode及学习线程 进入了main函数,我们走出了第一步,接下来看看再怎么走: public class DataNode extends Config ...
- Android学习笔记之LinearLayout
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...
- 物联网大赛 - Android学习笔记(一) Android概念
一.Android 概念 Android是开放式的手机和电脑操作系统,是基于Linux系统做的上层开发. android可以做些什么? Android可以开发各种手机应用APP,也可以开发车载系统等, ...
- android学习笔记50——SQLiteOpenHelper、android实现系统自带样式
SQLiteOpenHelper SQLiteOpenHelper是android提供的一个管理数据库的工具类,可用于管理数据库的创建和版本更新. 一般的用法是创建SQLiteOpenHelper的子 ...
- 【Android学习笔记】Mac下Android Studio开发环境搭建
本文由@ray 出品,转载请注明出处. 文章链接:http://www.cnblogs.com/wolfray/p/7829069.html 对于移动端这块,笔者之前一直都是进行iOS开发的,也从来 ...
- ffmpeg学习笔记-Linux下编译Android动态库
Android平台要使用ffmpeg就需要编译生成动态库,这里采用Ubuntu编译Android动态库 文件准备 要编译生成Android需要以下文件 NDK ffmpeg源代码 NDK下载 NDK可 ...
- Unity3D之移植学习笔记:移植到Android平台更好的方法
接上文,之前我们采用了直接将Unity项目导出为Eclipse项目来修改的方式,这种做法存在的一个最大的问题就是:每当Unity被修改之后,都需要重新导出,而每次导出的项目在Android平台方面的J ...
- (1)-Android学习笔记之:初识Android系统架构和项目结构
Android系统架构 Android程序结构 创建一个Android项目,为初学便于理解,将程序项目结构切换为Project模式,项目结构如下 .gradle和.idea:这两个目录下放的都是And ...
随机推荐
- poj3264 倍增法(ST表)裸题
打出st表的步骤:1:建立初始状态,2:区间按2的幂从小到大求出值 3:查询时按块查找即可 #include<iostream> #include<cstring> #incl ...
- 数论知识点总结(noip范围)
数论知识点: 约数个数和约数和公式(例题:POJ1845 分治思想): 质因数分解 p1^k1xp2^k2xp3^k3...pn^kn 约数个数和:(1+k1)(1+k2)...(1+kn) 所有约数 ...
- 文件中用WriteLine追加内容的两种方法
if (!Directory.Exists("C:\\testll")) { Directory.CreateDirectory("C:\\testll"); ...
- 《LINQ技术详解C#》-2.查询表达式翻译为标准查询操作符
(1)透明标识符 有些翻译步骤要使用透明标识符(*)插入枚举变量. 透明标识符只在翻译过程中存在,翻译结束将不再出现. (2)翻译步骤 ①带有into连续语句的Select和Group语句 from. ...
- Oracle 11.2.0.4 For Windows 64bit+32bit 数据库
1.Oracle11G 32BIT介质官方链接 适用于Windows 32bit的Oracle Database 11G 第2版U4(11.2.0.4)Oracle11.2.0.4 Windows3 ...
- ActiveMQ、RabbitMQ、RocketMQ、Kafka有什么优点和缺点
ActiveMQ 单机吞吐量:万级 topic数量都吞吐量的影响: 时效性:ms级 可用性:高,基于主从架构实现高可用性 消息可靠性:有较低的概率丢失数据 功能支持:MQ领域的功能极其完备 总结: 非 ...
- c++ primer 笔记 (二)
第二章笔记 (貌似记得有点多) 把负值赋给unsigned对象时完全合法的,其结果是该负数对该类型的取值个数求模后的值 -1 (对265求模) 255 float型只能保证6位 ...
- Python divmod方法
有95条数据 每十条存一页 all_item = 95 pager = 10 result = all_item.__divmod__(pager) print(result) (9{商},5{余数} ...
- 【LeetCode】161. One Edit Distance
Difficulty: Medium More:[目录]LeetCode Java实现 Description Given two strings S and T, determine if the ...
- VB.NET 编程元素支持更改总结
Visual Basic 2005 更改了它支持各种编程元素的方式,主要是为了提供与公共语言运行库的互操作性.许多 Visual Basic 6.0 元素被重新命名,重新分类或与 Visual Bas ...