一,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学习的更多相关文章

  1. Flutter学习笔记(30)--Android原生与Flutter混编

    如需转载,请注明出处:Flutter学习笔记(30)--Android原生与Flutter混编 这篇文章旨在学习如何在现有的Android原生项目上集成Flutter,实现Android与Flutte ...

  2. Hadoop源码学习笔记(3) ——初览DataNode及学习线程

    Hadoop源码学习笔记(3) ——初览DataNode及学习线程 进入了main函数,我们走出了第一步,接下来看看再怎么走: public class DataNode extends Config ...

  3. Android学习笔记之LinearLayout

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  4. 物联网大赛 - Android学习笔记(一) Android概念

    一.Android 概念 Android是开放式的手机和电脑操作系统,是基于Linux系统做的上层开发. android可以做些什么? Android可以开发各种手机应用APP,也可以开发车载系统等, ...

  5. android学习笔记50——SQLiteOpenHelper、android实现系统自带样式

    SQLiteOpenHelper SQLiteOpenHelper是android提供的一个管理数据库的工具类,可用于管理数据库的创建和版本更新. 一般的用法是创建SQLiteOpenHelper的子 ...

  6. 【Android学习笔记】Mac下Android Studio开发环境搭建

    本文由@ray 出品,转载请注明出处.  文章链接:http://www.cnblogs.com/wolfray/p/7829069.html 对于移动端这块,笔者之前一直都是进行iOS开发的,也从来 ...

  7. ffmpeg学习笔记-Linux下编译Android动态库

    Android平台要使用ffmpeg就需要编译生成动态库,这里采用Ubuntu编译Android动态库 文件准备 要编译生成Android需要以下文件 NDK ffmpeg源代码 NDK下载 NDK可 ...

  8. Unity3D之移植学习笔记:移植到Android平台更好的方法

    接上文,之前我们采用了直接将Unity项目导出为Eclipse项目来修改的方式,这种做法存在的一个最大的问题就是:每当Unity被修改之后,都需要重新导出,而每次导出的项目在Android平台方面的J ...

  9. (1)-Android学习笔记之:初识Android系统架构和项目结构

    Android系统架构 Android程序结构 创建一个Android项目,为初学便于理解,将程序项目结构切换为Project模式,项目结构如下 .gradle和.idea:这两个目录下放的都是And ...

随机推荐

  1. STL整理之map

    转载请注明出处,部分内容引自李煜东<算法竞赛进阶指南> 前置知识:    C++.C语言入门 Map是什么 Map是从键(key)到值(value)的映射,其内部实现是一棵以key为关键码 ...

  2. 步步为营-55-js练习

    1:加法计算器 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head&g ...

  3. JavaScript脚本的两种放置方式

    JavaScript脚本的两种放置方式 1在body里用 script标签引用 2 直接写在<script></script>标签之中

  4. Kubernetes图形化归纳总结基础介绍整理

    今天了解了下k8s,看了很多资料,自己归纳总结下,如果需要测试集群的话需要准备三台Linux服务器,一台做Master,其余两台作为Node仆从(MINION)节点, 先说下Node节点,就是宿主机器 ...

  5. ThreadPoolExecutor线程池的分析和使用

    1. 引言 合理利用线程池能够带来三个好处. 第一:降低资源消耗.通过重复利用已创建的线程降低线程创建和销毁造成的消耗. 第二:提高响应速度.当任务到达时,任务可以不需要等到线程创建就能立即执行. 第 ...

  6. Swagger 常用注解

    一.Swagger常用注解 1.与模型相关的注解 两个注解: @ApiModel:用在模型类上,对模型类做注释: @ApiModelProperty:用在属性上,对属性做注释 2.与接口相关的注解 六 ...

  7. div+css中height:auto !important; height:663px; min-height:663px !important;区别

    height:auto !important是高度自适应,主要的是,!important只是对于ie6不认识而已,其他浏览器都是以这个为最高的优先级,执行这个,ie6会无视这个,不是只有火狐而已hei ...

  8. VSCode从非根目录编译golang程序(转)

    1.问题提出 “习惯在项目目录里建src放源码文件,根目录里放配置文件或者别的什么,在交付时直接忽视掉src目录就行了,但vscode好像不能这样愉快的玩耍...”??? 要实现把源码放到src目录下 ...

  9. Progressive web app理念及发展前景

    前一段时间微信推出微信小程序进行公测,着实火了一把,博得了大众的眼球,不明真相的吃瓜观众们纷纷围观,所谓的“微信小程序”,通俗的讲就是一种不需要下载安装即可使用的应用程序,脱离于app商店依托于浏览器 ...

  10. AGC 016C.+/- Rectangle(思路 构造)

    题目链接 首先想到同样例1的构造方式.即不得不填负的格子填\(-h*w\),其余填\(1\).直接这样能过二三十个点. 只这样不对.比如1 4 1 3,会输出无解(会填[1 1 -3 1]).怎么改呢 ...