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 ...
随机推荐
- 【ES】学习6-多字段搜索1
本系列的笔记都来自:https://elasticsearch.cn/book/elasticsearch_definitive_guide_2.x/multi-field-search.html 下 ...
- 欧拉函数,打表求欧拉函数poj3090
欧拉函数 φ(n) 定义:[1,N]中与N互质的数的个数 //互质与欧拉函数 /* 求欧拉函数 按欧拉函数计算公式,只要分解质因数即可 */ int phi(int n){ int ans=n; ;i ...
- pytest十一:函数传参和 firture 传参数 request
为了提高代码的复用性,我们在写用例的时候,会用到函数,然后不同的用例去调用这个函数.比如登录操作,大部分的用例都会先登录,那就需要把登录单独抽出来写个函数,其它用例全部的调用这个登录函数就行.但是登录 ...
- python 全栈开发,Day132(玩具管理页面,控制玩具通讯录,基于请求的好友关系建立)
先下载github代码,下面的操作,都是基于这个版本来的! https://github.com/987334176/Intelligent_toy/archive/v1.5.zip 注意:由于涉及到 ...
- PTA之求单链表结点的阶乘和
本题要求实现一个函数,求单链表L结点的阶乘和.这里默认所有结点的值非负,且题目保证结果在int范围内. 时间限制: 400ms 内存限制: 64MB 代码长度限制: 16KB 函数接口定义: int ...
- Using jconsole to connect to JMX on AS7
Using jconsole to connect to JMX on AS7 https://developer.jboss.org/wiki/UsingJconsoleToConnectToJMX ...
- 和组合数有关的dp
1. UVaLive 7143 Room Assignment 用dp[i][r]表示,前i个盒子已经放完了,手上还拿着r对同色球. 状态转移方程为:dp[i+1][r-a-b] = dp[i][r] ...
- C#对Windows文件/文件夹/目录的一些操作总结
1. 在一个目录下创建一个文件夹 if (!System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path); ...
- Python高级正则
import re p = re.compile("^[0-9]") m = p.match('13435aSAdb') print(m.group()) 一.上面的第二行和第三行 ...
- Centos 6.5安装mysql
转载自:https://www.cnblogs.com/leffss/p/8512773.html 一.安装前准备 安装采用二进制包方式,软件包5.7.19版本下载地址:https://dev.mys ...