和我一起看API(一)你所不知道的LinearLayout补充
楼主英语水平差,翻译的不好的话请多多指正,嘿嘿。。。
A Layout that arranges its children in a single column or a single row. The direction of* the row canbe set by
calling {@link #setOrientation(int) setOrientation()}.* You can also specify gravity, which specifies the
alignment of all the child elements by* calling {@link #setGravity(int) setGravity()} or specify that specific
children* grow to fill up any remaining space in the layout by setting the <em>weight</em> member of
{@link android.widget.LinearLayout.LayoutParams LinearLayout.LayoutParams}.* The default orientation is
horizontal.
这是一个将子类排列在一列或一行的布局。通过调用 setOrientation()可以设置行的方向。您还可以指定对其方向,它指定
所有子元素的对齐方式的方法叫做{ @link # setGravity(int)setGravity()}或通过设置权重/weight(< em > < / em >的
成员)指定特定的子类填满剩余的空间布局 { @link android.widget.LinearLayout。LayoutParams LinearLayout.
LayoutParams }。默认的方向是水平的。
/**
* Don't show any dividers.
*不显示任何分割线
*/
public static final int SHOW_DIVIDER_NONE = 0;
/**
* Show a divider at the beginning of the group.
* 显示分割线在这个视图组之前
*/
public static final int SHOW_DIVIDER_BEGINNING = 1;
/**
* 显示分割线在这个布局的每个子视图之间
* Show dividers between each item in the group.
*/
public static final int SHOW_DIVIDER_MIDDLE = 2;
/**
*显示分割线在这个布局的最后
* Show a divider at the end of the group.
*/
public static final int SHOW_DIVIDER_END = 4;
首先画一根线,采用shape.xml绘制:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:shape = "rectangle">
<size
android:width= "@dimen/fab_margin"
android:height= "@dimen/fab_margin" />
<solid android:color= "#ff00ff" />
</shape>
示例代码1设置分割线显示在子类最前方:
<LinearLayout
android:layout_width="fill_parent"
android:gravity="center"
android:divider="@drawable/driver"<!--设置分割线样式-->
android:showDividers="beginning"<!--设置分割线显示方式-->
android:layout_height="fill_parent"
android:orientation="horizontal">
<Button
android:id="@+id/bt1"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="1"/>
<Button
android:id="@+id/bt2"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="2"/>
<Button
android:id="@+id/bt3"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="3"/>
</LinearLayout>
示例2显示分割线在这个布局的每个子视图之间:
<LinearLayout
android:layout_width="fill_parent"
android:gravity="center"
android:divider="@drawable/driver"
android:showDividers="end"
android:layout_height="fill_parent"
android:orientation="horizontal">
<Button
android:id="@+id/bt1"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="1"/>
<Button
android:id="@+id/bt2"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="2"/>
<Button
android:id="@+id/bt3"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="3"/>
</LinearLayout>
示例3*显示分割线在这个布局的最后:
<LinearLayout
android:layout_width="fill_parent"
android:gravity="center"
android:divider="@drawable/driver"<!--设置分割线样式-->
android:showDividers="middle"<!--设置分割线显示方式-->
android:layout_height="fill_parent"
android:orientation="horizontal">
<Button
android:id="@+id/bt1"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="1"/>
<Button
android:id="@+id/bt2"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="2"/>
<Button
android:id="@+id/bt3"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="3"/>
</LinearLayout>
示例4*显示分割线在这个布局的前后中间:
<LinearLayout
android:layout_width="fill_parent"
android:gravity="center"
android:divider="@drawable/driver"<!--设置分割线样式-->
android:showDividers="middle|beginning|end"<!--设置分割线显示方式-->
android:layout_height="fill_parent"
android:orientation="horizontal">
<Button
android:id="@+id/bt1"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="1"/>
<Button
android:id="@+id/bt2"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="2"/>
<Button
android:id="@+id/bt3"
android:layout_width="120dp"
android:layout_height="60dp"
android:text="3"/>
</LinearLayout>
/**
* Set padding displayed on both ends of dividers.
*
* @param padding Padding value in pixels that will be applied to each end
*
* @see #setShowDividers(int)
* @see #setDividerDrawable(Drawable)
* @see #getDividerPadding()
*/
/ * *
*设置内边距显示分隔器的两端。
*
* @param内边距的值将会使用像素作为单位
*
* @see # setShowDividers(int)
* @see # setDividerDrawable(可移动)
* @see # getDividerPadding()
* /
public void setDividerPadding(int padding) {
mDividerPadding = padding;
}
android:dividerPadding="12dp"
3、
/**
* Whether the children of this layout are baseline aligned. Only applicable
* if {@link #mOrientation} is horizontal.
*/
@ViewDebug.ExportedProperty(category = "layout")
private boolean mBaselineAligned = true;
这种布局的子视图是否基线对齐。只适用水平布局--注:基线是在中间
xml代码只需要在LinearLayout布局中添加属性:
android:baselineAligned="true"
*{ @link # mOrientation }
If this layout is part of another layout that is baseline aligned,
* use the child at this index as the baseline.
*
* Note: this is orthogonal to {@link #mBaselineAligned}, which is concerned
* with whether the children of this layout are baseline aligned.
@ViewDebug.ExportedProperty(category = "layout")
*/
@ViewDebug.ExportedProperty(category = "layout")
private int mBaselineAlignedChildIndex = -1;
private int mBaselineAlignedChildIndex = -1;
如果这个布局是另一个基线对齐的布局的一部分,
*使用子视图在这个指数作为基准。
*
*注:这是正交于{ @link # mBaselineAligned },这是担心
*此布局的子视图是否基线对齐。
android:baselineAlignedChildIndex="-1"
/**
* When true, all children with a weight will be considered having
* the minimum size of the largest child. If false, all children are
* measured normally.
*
* @return True to measure children with a weight using the minimum
* size of the largest child, false otherwise.
*
* @attr ref android.R.styleable#LinearLayout_measureWithLargestChild
*/
public boolean isMeasureWithLargestChildEnabled() {
return mUseLargestChild;
}
/ * *
当为真的时候 具有相同权重/比重的所有子类被认为是最大子类的最小权重
如果为假 所有子类测量和平时权重/比重一样
android:measureWithLargestChild="true"
从今晚开始每晚翻译一点,贵在坚持。。。坚持大叔
和我一起看API(一)你所不知道的LinearLayout补充的更多相关文章
- 你所不知道的 CSS 阴影技巧与细节 滚动视差?CSS 不在话下 神奇的选择器 :focus-within 当角色转换为面试官之后 NPOI 教程 - 3.2 打印相关设置 前端XSS相关整理 委托入门案例
你所不知道的 CSS 阴影技巧与细节 关于 CSS 阴影,之前已经有写过一篇,box-shadow 与 filter:drop-shadow 详解及奇技淫巧,介绍了一些关于 box-shadow ...
- 你所不知道的linq(二)
上一篇说了from in select的本质,具体参见你所不知道的linq.本篇说下from...in... from... in... select 首先上一段代码,猜猜结果是什么? class P ...
- 你所不知道的库存超限做法 服务器一般达到多少qps比较好[转] JAVA格物致知基础篇:你所不知道的返回码 深入了解EntityFramework Core 2.1延迟加载(Lazy Loading) EntityFramework 6.x和EntityFramework Core关系映射中导航属性必须是public? 藏在正则表达式里的陷阱 两道面试题,带你解析Java类加载机制
你所不知道的库存超限做法 在互联网企业中,限购的做法,多种多样,有的别出心裁,有的因循守旧,但是种种做法皆想达到的目的,无外乎几种,商品卖的完,系统抗的住,库存不超限.虽然短短数语,却有着说不完,道不 ...
- 你所不知道的setInterval
在你所不知道的setTimeout记载了下setTimeout相关,此篇则整理了下setInterval:作为拥有广泛应用场景(定时器,轮播图,动画效果,自动滚动等等),而又充满各种不确定性的这set ...
- 你所不知道的setTimeout
JavaScript提供定时执行代码的功能,叫做定时器(timer),主要由setTimeout()和setInterval()这两个函数来完成.它们向任务队列添加定时任务.初始接触它的人都觉得好简单 ...
- 你真的会玩SQL吗?你所不知道的 数据聚合
你真的会玩SQL吗?系列目录 你真的会玩SQL吗?之逻辑查询处理阶段 你真的会玩SQL吗?和平大使 内连接.外连接 你真的会玩SQL吗?三范式.数据完整性 你真的会玩SQL吗?查询指定节点及其所有父节 ...
- 你所不知道的SQL Server数据库启动过程,以及启动不起来的各种问题的分析及解决技巧
目前SQL Server数据库作为微软一款优秀的RDBMS,其本身启动的时候是很少出问题的,我们在平时用的时候,很少关注起启动过程,或者很少了解其底层运行过程,大部分的过程只关注其内部的表.存储过程. ...
- 你所不知道的SQL Server数据库启动过程(用户数据库加载过程的疑难杂症)
前言 本篇主要是上一篇文章的补充篇,上一篇我们介绍了SQL Server服务启动过程所遇到的一些问题和解决方法,可点击查看,我们此篇主要介绍的是SQL Server启动过程中关于用户数据库加载的流程, ...
- Android中Context详解 ---- 你所不知道的Context
转自:http://blog.csdn.net/qinjuning/article/details/7310620Android中Context详解 ---- 你所不知道的Context 大家好, ...
随机推荐
- 用scikit-learn学习主成分分析(PCA)
在主成分分析(PCA)原理总结中,我们对主成分分析(以下简称PCA)的原理做了总结,下面我们就总结下如何使用scikit-learn工具来进行PCA降维. 1. scikit-learn PCA类介绍 ...
- ASP.NET Core 中间件之压缩、缓存
前言 今天给大家介绍一下在 ASP.NET Core 日常开发中用的比较多的两个中间件,它们都是出自于微软的 ASP.NET 团队,他们分别是 Microsoft.AspNetCore.Respons ...
- Python的单元测试(二)
title: Python的单元测试(二) date: 2015-03-04 19:08:20 categories: Python tags: [Python,单元测试] --- 在Python的单 ...
- [版本控制之道] Git 常用的命令总结(欢迎收藏备用)
坚持每天学习,坚持每天复习,技术永远学不完,自己永远要前进 总结日常开发生产中常用的Git版本控制命令 ------------------------------main-------------- ...
- JAVA问题集锦Ⅰ
1.Java的日期添加: import java.util.Date ; date=new date();//取时间 Calendar calendar = new GregorianCalendar ...
- 运用php做投票题,例题
要求大概是这样的,有一个题目,题目下面是复选框,要求点完复选框提交后会变成进度条,各选项的进度条百分比,和投票数量 首先还是要在数据库建两张表,如下: 要完成这个题目,需要建两个页面 <!DOC ...
- .NET Core的日志[2]:将日志输出到控制台
对于一个控制台应用,比如采用控制台应用作为宿主的ASP.NET Core应用,我们可以将记录的日志直接输出到控制台上.针对控制台的Logger是一个类型为ConsoleLogger的对象,Consol ...
- 带你实现开发者头条APP(三) 首页实现
title: 带你实现开发者头条APP(三) 首页实现 tags: 轮播广告,ViewPager切换,圆形图片 grammar_cjkRuby: true --- 一.前言 今天实现开发者头条APP的 ...
- Redis的简单动态字符串实现
Redis 没有直接使用 C 语言传统的字符串表示(以空字符结尾的字符数组,以下简称 C 字符串), 而是自己构建了一种名为简单动态字符串(simple dynamic string,sds)的抽象类 ...
- 创建APPID&&部署服务端教程
创建APPID&&部署服务端 一.创建APPID 1.打开https://console.developers.google.com ,左击顶部Project,然后左击创建项目 2.输 ...