关于LayoutParams
每一个布局均有一个叫LayoutParams的内部类,如:
LinearLayout.LayoutParams
RelativeLayout.LayoutParams
AbsoluteLayout.LayoutParams
TableLayout.LayoutParams
TableLayout.LayoutParams
FrameLayout.LayoutParams
此内部类用于指明某个view在其父元素中的位置,以linearLayout为例:
Per-child
layout information associated with LinearLayout.
Standard
gravity constant that a child supplies to its parent. Defines how the child view should be positioned, on both the X and Y axes, within its enclosing layout.
在LinearLayout中,只有2个xml属性:layout_gravity, layout_weight
但在RelativeLayout中,由于其涉及较多的位置选项,因此有多个xml属性:
| Attribute Name | Related Method | Description |
| android:layout_above | Positions the bottom edge of this view above the given anchor view ID. | |
| android:layout_alignBaseline | Positions the baseline of this view on the baseline of the given anchor view ID. | |
| android:layout_alignBottom | Makes the bottom edge of this view match the bottom edge of the given anchor view ID. | |
| android:layout_alignEnd | Makes the end edge of this view match the end edge of the given anchor view ID. | |
| android:layout_alignLeft | Makes the left edge of this view match the left edge of the given anchor view ID. | |
| android:layout_alignParentBottom | If true, makes the bottom edge of this view match the bottom edge of the parent. | |
| android:layout_alignParentEnd | If true, makes the end edge of this view match the end edge of the parent. | |
| android:layout_alignParentLeft | If true, makes the left edge of this view match the left edge of the parent. | |
| android:layout_alignParentRight | If true, makes the right edge of this view match the right edge of the parent. | |
| android:layout_alignParentStart | If true, makes the start edge of this view match the start edge of the parent. | |
| android:layout_alignParentTop | If true, makes the top edge of this view match the top edge of the parent. | |
| android:layout_alignRight | Makes the right edge of this view match the right edge of the given anchor view ID. | |
| android:layout_alignStart | Makes the start edge of this view match the start edge of the given anchor view ID. | |
| android:layout_alignTop | Makes the top edge of this view match the top edge of the given anchor view ID. | |
| android:layout_alignWithParentIfMissing | If set to true, the parent will be used as the anchor when the anchor cannot be be found for layout_toLeftOf, layout_toRightOf, etc. | |
| android:layout_below | Positions the top edge of this view below the given anchor view ID. | |
| android:layout_centerHorizontal | If true, centers this child horizontally within its parent. | |
| android:layout_centerInParent | If true, centers this child horizontally and vertically within its parent. | |
| android:layout_centerVertical | If true, centers this child vertically within its parent. | |
| android:layout_toEndOf | Positions the start edge of this view to the end of the given anchor view ID. | |
| android:layout_toLeftOf | Positions the right edge of this view to the left of the given anchor view ID. | |
| android:layout_toRightOf | Positions the left edge of this view to the right of the given anchor view ID. | |
| android:layout_toStartOf | Positions the end edge of this view to the start of the given anchor view ID. |
总而言之,LayoutParams子类用于指定某个元素的位置信息。
关于LayoutParams的更多相关文章
- WindowManager.LayoutParams 札记
WindowManager.LayoutParams wlp = new WindowManager.LayoutParams(width, height, WindowManager.LayoutP ...
- [Android] 转-LayoutInflater丢失View的LayoutParams
原文地址:http://lmbj.net/blog/layoutinflater-and-layoutparams/ View view = inflater.inflate(R.layout.ite ...
- 安卓冷知识:LayoutParams
安卓的布局有很多种,每种都有对应的LayoutParams类,那么它们之间到底是什么关系? 为什么在编写Layout的XML文件时,有的layout_前缀属性有用有的没有用? 一句话道出LayoutP ...
- 通过inflate获取布局,设置layoutparams无效
给ll——addtiem当设置layoutparams无效时,试着修改上一个布局的属性
- ListView的LayoutParams设置
// Temp is the root view that was found in the xml final View temp = createViewFromTag(root, name, a ...
- Android LayoutParams简介
LayoutParams是子控件控制自己在父控件中布局的一个类. 不同布局都有相对的LayoutParams,最简单的LinearLayout.LayoutParams类可以设置布局的宽高. 我在写一 ...
- 简单研究Android View绘制二 LayoutParams
2015-07-28 17:23:20 本篇是关于LayoutParams相关 ViewGroup.LayoutParams文档解释如下: LayoutParams are used by views ...
- RelativeLayout.LayoutParams.addRule()方法
1.应用场景 在使用RelativeLayout布局的时候,通常在载入布局之前在相关的XML文件中进行静态设置即可.但是,在有些情况下,我们需要动态的设置布局 的属性,在不同条件下设置不同的布局排列方 ...
- android中的layoutparams参数使用的简单总结
定义: 我们可以在Android的framework中的ViewGroup类里找到定义的类: public static class LayoutParams{...} 此类有如下注释: Layout ...
- LayoutParams使用
LayoutParams继承于Android.View.ViewGroup.LayoutParams. LayoutParams相当于一个Layout的信息包,它封装了Layout的位置. ...
随机推荐
- phpmyadmin开启远程服务器连接
1.修改 braries/config.default.php,将 $cfg['AllowArbitraryServer'] 的值由 false 改成 true. 2.有其他需求的也可以自己在这里修 ...
- 【好程序员笔记分享】——URL解码与编码
-iOS培训,iOS学习-------型技术博客.期待与您交流!------------ 1.url编码 ios中http请求遇到汉字的时候,需要转化成UTF-8,用到的方法是: NSString * ...
- Http GET、Post方式的请求总结
读取http响应信息,并返回响应体 /// <summary> /// 读取http响应信息,并返回响应体 /// </summary> /// <param name= ...
- abiword rtf 解析
目前为止,代码跟进,知道是这个地方进行文件解析的 T_Error IE_Imp_RTF::importFile(const char * szFilename)
- ubuntu vim YCM
http://blog.sina.com.cn/s/blog_499386b00100rxm1.html http://www.cnblogs.com/junnyfeng/p/3633697.html
- Android中读取assets文件夹中的子文件夹内容
文件结构如下:assets/info/info AssetManager am = this.getResources().getAssets(); InputStream input = null; ...
- 自己动手写谷歌API翻译接口
可以看到,利用GET请求方式,带入某些参数,就会返回一个json数组,QueryString参数如下: 同样的,我们只需要传入这三个参数,就可以获得我们想要的翻译内容,公开方法,代码如下. ...
- 数据结构之单链表,c#实现
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- RFC 2327--SDP
Network Working Group M. Handley Request for Comments: 2327 V. Jacobson Category: Standards Track IS ...
- mongodb----修改器
$inc:增加或者减少指定键值,如果键不存在,就创建一个键. $set:指定一个健的值,如果键不存在,就创建一个键. $unset:删除指定的键. $push:向指定的数组末尾加添加一个元素,如果数组 ...