关于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的位置. ...
随机推荐
- 搭建hbase-0.94.26集群环境
先安装hadoop1.2.1,见http://blog.csdn.net/jediael_lu/article/details/38926477 1.配置hbase-site.xml <prop ...
- [UVA] 11995 - I Can Guess the Data Structure! [STL应用]
11995 - I Can Guess the Data Structure! Time limit: 1.000 seconds Problem I I Can Guess the Data Str ...
- 完美解决ListView 与 ScrollView 共存问题
1:首先设置ListView的高度,在setAdapter之后调用此方法. public static void setListViewHeightBasedOnChildren(ListView l ...
- BZOJ3144 切糕
http://www.lydsy.com/JudgeOnline/problem.php?id=3144 思路:如果没有D的限制,那一个竖轴都是一个最小割,每个点向更高的点引一条流量为自己权值的边,那 ...
- vs 自动生成core dump文件
一直以来觉着core dump这个东西很神奇,在初步学习的时候也没有个大方向,最近项目需要记录程序崩溃时的日志信息,因此在网上寻找相关的信息,此时core dump也成为了我重点关注的东西. 说说我的 ...
- 关于BitmapFactory.decodeStream(is)方法无法正常解码为Bitmap对象的解决方法
在android sdk 1.6版本API帮助文档中,其中关于BitmapFactory.decodeFactory.decodeStream(InputStream is)的帮助文档是这么说明的: ...
- Grok 正则捕获
Grok 正则捕获: \s+(?<request_time>\d+(?:\.\d+)?)\s+ 回顾下: (?:pattern) 匹 配 pattern 但不获取匹配结果,也就是说这是一个 ...
- Django学习笔记(精简版)
dos:安装:python setup.py install 环境变量:D:\Python27;D:\Python27\Lib\site-packages\django\bin; 转到创建的目录:dj ...
- C 本地文件夸网文件Cp操作
1,linux平台C简单实现本地文件cp 码子及运行效果测试
- ZooKeeper架构设计及其应用
ZooKeeper是一个开源的分布式服务框架,它是Apache Hadoop项目的一个子项目,主要用来解决分布式应用场景中存在的一些问题,如:统一命名服务.状态同步服务.集群管理.分布式应用配置管理等 ...