关于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的位置. ...
随机推荐
- IOS 面试 --- 网络部分
网络部分 3 做过的项目是否涉及网络访问功能,使用什么对象完成网络功能? 答案:ASIHTTPRequest与NSURLConnection 4 简单介绍下NSURLConnection类及+ sen ...
- 163k地方门户网站系统自动审核信息脚本
本代码实现对163k地方门户网站系统发布信息的自动审核,以及对内容中链接全过滤 软件安装 Python 安装 http://www.python.org/download/ pymssql安装 htt ...
- 在开启bin-log日志下Mysql报错
This function has none of DETERMINISTIC, NO SQL解决办法 创建存储过程时 出错信息: ERROR 1418 (HY000): This function ...
- ListView中RadioButton实现单项选择
1:FragmentHack5.java public class FragmentHack5 extends Fragment { View view; ListView lvCountries; ...
- Ubuntu mysql中文乱码解决
#vim /etc/mysql/my.cnf 找到[mysqld]添加 character-set-server = utf8 重启mysql #restart mysql mysql> sho ...
- android获取sdk更新
http://www.th7.cn/Program/Android/201310/154981.shtml 网上许多解决 Android SDK Manager 无法更新(下载)的问题的方法基本都是将 ...
- cf A. Vasily the Bear and Triangle
http://codeforces.com/contest/336/problem/A #include <cstdio> #include <cstring> #includ ...
- 模拟IIC总线汇编程序软件包
一.概述 为了非常方便地对 I2C 从器件进行快速的.正确的读写操作,我们为此而设计出虚拟 I2C 总线操作平台软件包.本软件包是主方式下的虚拟 I2C 总线软件包,只要用户给子程序提供几个主要的参数 ...
- 2016"百度之星" - 资格赛(Astar Round1) 1001
思路:第一个做法就是:每读入起始位置i和结束位置j,就从这位置i到位置j计算,可是TLE了,后面我想想要是我输入一个最长的字符串,且以最大次数计算开始位置1到结束位置100000,那么这计算量是很大的 ...
- 【转】网络视频监控P2P解决方案
一.摘要 本文分析了日益增长的民用级别家庭和个人网络视频监控市场的需求特点,并给出了一种经济可行易于大规模部署的P2P解决方案. 由于篇幅有限,本文只给出了方案的思路,未对更深入的技术细节做详细的论述 ...