addRule方法就要带一个view的id值

有了这个addRule方法就可以设置很多其他属性了,通过源码可知RelativeLayout是使用mRules这个数组来记录哪种属性使用到了,一共有22种属性:

/**
* Rule that aligns a child's right edge with another child's left edge.
*/
public static final int LEFT_OF = 0;
/**
* Rule that aligns a child's left edge with another child's right edge.
*/
public static final int RIGHT_OF = 1;
/**
* Rule that aligns a child's bottom edge with another child's top edge.
*/
public static final int ABOVE = 2;
/**
* Rule that aligns a child's top edge with another child's bottom edge.
*/
public static final int BELOW = 3;

/**
* Rule that aligns a child's baseline with another child's baseline.
*/
public static final int ALIGN_BASELINE = 4;
/**
* Rule that aligns a child's left edge with another child's left edge.
*/
public static final int ALIGN_LEFT = 5;
/**
* Rule that aligns a child's top edge with another child's top edge.
*/
public static final int ALIGN_TOP = 6;
/**
* Rule that aligns a child's right edge with another child's right edge.
*/
public static final int ALIGN_RIGHT = 7;
/**
* Rule that aligns a child's bottom edge with another child's bottom edge.
*/
public static final int ALIGN_BOTTOM = 8;

/**
* Rule that aligns the child's left edge with its RelativeLayout
* parent's left edge.
*/
public static final int ALIGN_PARENT_LEFT = 9;
/**
* Rule that aligns the child's top edge with its RelativeLayout
* parent's top edge.
*/
public static final int ALIGN_PARENT_TOP = 10;
/**
* Rule that aligns the child's right edge with its RelativeLayout
* parent's right edge.
*/
public static final int ALIGN_PARENT_RIGHT = 11;
/**
* Rule that aligns the child's bottom edge with its RelativeLayout
* parent's bottom edge.
*/
public static final int ALIGN_PARENT_BOTTOM = 12;

/**
* Rule that centers the child with respect to the bounds of its
* RelativeLayout parent.
*/
public static final int CENTER_IN_PARENT = 13;
/**
* Rule that centers the child horizontally with respect to the
* bounds of its RelativeLayout parent.
*/
public static final int CENTER_HORIZONTAL = 14;
/**
* Rule that centers the child vertically with respect to the
* bounds of its RelativeLayout parent.
*/
public static final int CENTER_VERTICAL = 15;
/**
* Rule that aligns a child's end edge with another child's start edge.
*/
public static final int START_OF = 16;
/**
* Rule that aligns a child's start edge with another child's end edge.
*/
public static final int END_OF = 17;
/**
* Rule that aligns a child's start edge with another child's start edge.
*/
public static final int ALIGN_START = 18;
/**
* Rule that aligns a child's end edge with another child's end edge.
*/
public static final int ALIGN_END = 19;
/**
* Rule that aligns the child's start edge with its RelativeLayout
* parent's start edge.
*/
public static final int ALIGN_PARENT_START = 20;
/**
* Rule that aligns the child's end edge with its RelativeLayout
* parent's end edge.
*/
public static final int ALIGN_PARENT_END = 21;
---------------------

转载于:https://www.cnblogs.com/hyhy904/p/11379394.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值