Android allows a control (layout layout properties) beneath another control

How to make a control in another control under direct operation in the following code:

<LinearLayout
    android:id="@+id/ly_dialogPersonCode_Title"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="10dp"
    android:gravity="center"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tv_dialogPersonCode_Title"
        android:layout_width="150dp"
        android:layout_height="60dp"
        android:text="个人码"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/white"
        android:gravity="center"
        android:textStyle="bold"
        android:paddingBottom="8dp"
        android:background="@drawable/person_code_title"
        android:textSize="20sp" />

</LinearLayout>

<TextView
    android:id="@+id/tv_dialogPersonCode_Number"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/tv_dialogPersonCode_Title"
    android:text="974693"
    android:textColor="@color/navyBlue"
    android:gravity="center"
    android:layout_gravity="center"
    android:textStyle="bold"
    android:ellipsize="end"
    android:singleLine="true"
    android:textSize="40sp" />

In this manner a relative layout manner, by reference to the layout. The following describes the concept of relative Vigor layout:

Relative layout, that is, with respect to the location of a reference to put new controls, represented by RelativeLayout class.

This layout key is to find a suitable frame of reference, reference can be divided into two categories:

1, the direct parent of the container;

2, Brothers controls.

Since each control only one parent container, when the reference to the parent container, an attribute value of true or false only two kinds.

There can be many sibling control, control through the unique id to distinguish, when as the reference to control sibling, brother id attribute value control.

When reference is determined, also specify the specific location relative to a reference orientation and alignment control can be more precisely specified, for example, reference is located above and aligned with the left reference like.
Layout relatively common layout attributes:

  • android: layout_centerHorizontal: Set if the control is located on the horizontal center of the parent container;
  • android: layout_centerVertical: setting the vertical position of whether the control center is located in the parent container;
  • android: layout_centerInParent: setting the center position is located in the control of the parent container;
  • android: layout_alignParentTop: Set the parent whether the control at the top of the container is aligned;
  • android: layout_alignParentBottom: whether the control is provided aligned with the bottom of the parent container;
  • android: layout_alignParentLeft: whether the control is provided aligned with the left end of the parent container;
  • android: layout_alignParentRight: setting whether the control is aligned with the right end of the parent container;
  • android: layout_toRightOf: set the control ID is located in the given control to the right;
  • android: layout_toLeftOf: setting the control is located on the left side of the given ID of the control;
  • android: layout_above: set the control is located above a predetermined ID of the control;
  • android: layout_below: to set the control is located under the control of a given ID;
  • android: layout_alignTop: set the control is aligned with a given ID of the control on the boundary;
  • android: layout_alignBottom: set the control aligned with the lower boundary of the given ID of the control;
  • android: layout_alignLeft: set the control aligned with the left margin of control given ID;
  • android: layout_alignRight: set the control right boundary aligned with the given ID of the control.

Guess you like

Origin blog.csdn.net/xuwei_net/article/details/88915299