RelativeLayout系列:RelativeLayout还有gravity属性?
Posted zhangjin1120
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RelativeLayout系列:RelativeLayout还有gravity属性?相关的知识,希望对你有一定的参考价值。
被下面这个代码惊讶到了,什么情况,RelativeLayout还有gravity属性?
看看源码,sdk\\platforms\\android-30\\data\\res\\values\\attrs.xml
,还真有。。。
我们常用android:layout_centerHorizontal="true"
,layout_centerHorizontal
这里面怎么没有?在RelativeLayout_Layout
里面:
<declare-styleable name="RelativeLayout_Layout">
<!-- Positions the right edge of this view to the left of the given anchor view ID.
Accommodates right margin of this view and left margin of anchor view. -->
<attr name="layout_toLeftOf" format="reference" />
<!-- Positions the left edge of this view to the right of the given anchor view ID.
Accommodates left margin of this view and right margin of anchor view. -->
<attr name="layout_toRightOf" format="reference" />
<!-- Positions the bottom edge of this view above the given anchor view ID.
Accommodates bottom margin of this view and top margin of anchor view. -->
<attr name="layout_above" format="reference" />
<!-- Positions the top edge of this view below the given anchor view ID.
Accommodates top margin of this view and bottom margin of anchor view. -->
<attr name="layout_below" format="reference" />
<!-- Positions the baseline of this view on the baseline of the given anchor view ID. -->
<attr name="layout_alignBaseline" format="reference" />
<!-- Makes the left edge of this view match the left edge of the given anchor view ID.
Accommodates left margin. -->
<attr name="layout_alignLeft" format="reference" />
<!-- Makes the top edge of this view match the top edge of the given anchor view ID.
Accommodates top margin. -->
<attr name="layout_alignTop" format="reference" />
<!-- Makes the right edge of this view match the right edge of the given anchor view ID.
Accommodates right margin. -->
<attr name="layout_alignRight" format="reference" />
<!-- Makes the bottom edge of this view match the bottom edge of the given anchor view ID.
Accommodates bottom margin. -->
<attr name="layout_alignBottom" format="reference" />
<!-- If true, makes the left edge of this view match the left edge of the parent.
Accommodates left margin. -->
<attr name="layout_alignParentLeft" format="boolean" />
<!-- If true, makes the top edge of this view match the top edge of the parent.
Accommodates top margin. -->
<attr name="layout_alignParentTop" format="boolean" />
<!-- If true, makes the right edge of this view match the right edge of the parent.
Accommodates right margin. -->
<attr name="layout_alignParentRight" format="boolean" />
<!-- If true, makes the bottom edge of this view match the bottom edge of the parent.
Accommodates bottom margin. -->
<attr name="layout_alignParentBottom" format="boolean" />
<!-- If true, centers this child horizontally and vertically within its parent. -->
<attr name="layout_centerInParent" format="boolean" />
<!-- If true, centers this child horizontally within its parent. -->
<attr name="layout_centerHorizontal" format="boolean" />
<!-- If true, centers this child vertically within its parent. -->
<attr name="layout_centerVertical" format="boolean" />
<!-- 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. -->
<attr name="layout_alignWithParentIfMissing" format="boolean" />
<!-- Positions the end edge of this view to the start of the given anchor view ID.
Accommodates end margin of this view and start margin of anchor view. -->
<attr name="layout_toStartOf" format="reference" />
<!-- Positions the start edge of this view to the end of the given anchor view ID.
Accommodates start margin of this view and end margin of anchor view. -->
<attr name="layout_toEndOf" format="reference" />
<!-- Makes the start edge of this view match the start edge of the given anchor view ID.
Accommodates start margin. -->
<attr name="layout_alignStart" format="reference" />
<!-- Makes the end edge of this view match the end edge of the given anchor view ID.
Accommodates end margin. -->
<attr name="layout_alignEnd" format="reference" />
<!-- If true, makes the start edge of this view match the start edge of the parent.
Accommodates start margin. -->
<attr name="layout_alignParentStart" format="boolean" />
<!-- If true, makes the end edge of this view match the end edge of the parent.
Accommodates end margin. -->
<attr name="layout_alignParentEnd" format="boolean" />
</declare-styleable>
以上是关于RelativeLayout系列:RelativeLayout还有gravity属性?的主要内容,如果未能解决你的问题,请参考以下文章
RelativeLayout系列:RelativeLayout还有gravity属性?
RelativeLayout中include 控件覆盖重叠的问题