每一个布局均有一个叫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的更多相关文章

  1. WindowManager.LayoutParams 札记

    WindowManager.LayoutParams wlp = new WindowManager.LayoutParams(width, height, WindowManager.LayoutP ...

  2. [Android] 转-LayoutInflater丢失View的LayoutParams

    原文地址:http://lmbj.net/blog/layoutinflater-and-layoutparams/ View view = inflater.inflate(R.layout.ite ...

  3. 安卓冷知识:LayoutParams

    安卓的布局有很多种,每种都有对应的LayoutParams类,那么它们之间到底是什么关系? 为什么在编写Layout的XML文件时,有的layout_前缀属性有用有的没有用? 一句话道出LayoutP ...

  4. 通过inflate获取布局,设置layoutparams无效

    给ll——addtiem当设置layoutparams无效时,试着修改上一个布局的属性

  5. ListView的LayoutParams设置

    // Temp is the root view that was found in the xml final View temp = createViewFromTag(root, name, a ...

  6. Android LayoutParams简介

    LayoutParams是子控件控制自己在父控件中布局的一个类. 不同布局都有相对的LayoutParams,最简单的LinearLayout.LayoutParams类可以设置布局的宽高. 我在写一 ...

  7. 简单研究Android View绘制二 LayoutParams

    2015-07-28 17:23:20 本篇是关于LayoutParams相关 ViewGroup.LayoutParams文档解释如下: LayoutParams are used by views ...

  8. RelativeLayout.LayoutParams.addRule()方法

    1.应用场景 在使用RelativeLayout布局的时候,通常在载入布局之前在相关的XML文件中进行静态设置即可.但是,在有些情况下,我们需要动态的设置布局 的属性,在不同条件下设置不同的布局排列方 ...

  9. android中的layoutparams参数使用的简单总结

    定义: 我们可以在Android的framework中的ViewGroup类里找到定义的类: public static class LayoutParams{...} 此类有如下注释: Layout ...

  10. LayoutParams使用

    LayoutParams继承于Android.View.ViewGroup.LayoutParams.       LayoutParams相当于一个Layout的信息包,它封装了Layout的位置. ...

随机推荐

  1. jquery的uploadify上传jsp+servlet

    1.准备材料:下载jquery.uploadify上传js   注意:这个上传在firefox下会出现问题如果你在项目中加了拦截器,因为session会丢失,所以你可以传参的时候带上你所需要的条件,在 ...

  2. php 与 jquery中$.post()与attr()方法的简单实例 amaze modal 模态窗口

    $(selector).attr(attribute,value)$.post() 在jqery中有这样一个方法,$.post()下面就这个方法做一个简单的实例: jQuery.post( url, ...

  3. jquery 做出专业的界面,SHOW 一下最近的成果~~~

    最近在项目中把整个UI框架重新做了一下,都是用Jquery实现的,没有使用EXT.EasyUI那一类的UI框架再也不用担心版权问题啦~~~~~~ 接下来我会在博客中把常用的功能分享出来,先上一下动态T ...

  4. easyui 实现Tooltip

    $('#btnAddr').tooltip({ content: $('<div class="table"></div>'), //弹出收件地址 show ...

  5. c# 弹出框-后台调前台函数

    前台代码: <script src="../../../Common/Scripts/Order/popup.js" type="text/javascript&q ...

  6. Learning Docker--chapter 1

    CONTENTS: (1) An introduction to Docker (2) Docker on Linux (3) Differentiating between containeriza ...

  7. keil c51 本變數型態(Variable Type)

    本變數型態(Variable Type): 類 別 符號位元 位元組(bytes) 表 示 法 數 值 範 圍 整 數 有 2 int(short) -32768~0~>32767 4 long ...

  8. [Android开发常见问题-18] Connection to https://dl-ssl.google.com refused

    在使用Android SDK Manager的时候,有时候会遇到上述问题,其实原因很简单,属于本地配置的问题. 解决方法: 1.以文本文件的方式打开“C:\Windows\System32\drive ...

  9. Shell函数返回值、删除函数、在终端调用函数

    Shell 也支持函数.Shell 函数必须先定义后使用. Shell 函数的定义格式如下: function_name () { list of commands [ return value ] ...

  10. [置顶] vi、akw和sed总结