android - How to use layout_below in RelativeLayout? -
here code(not code,i have deleted some):
<relativelayout android:id="@+id/info_in_my" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/head_in_my" android:layout_margintop="@dimen/spacing_size_36dp"> <imageview android:id="@+id/pic_in_my" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginstart="@dimen/spacing_size_36dp" android:layout_alignparentstart="true" android:src="@mipmap/icon_policeman" /> <textview android:id="@+id/name_in_my" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="aaaaaa" android:layout_toendof="@id/pic_in_my" android:layout_centerinparent="true" android:textcolor="@color/font_white" android:textsize="@dimen/font_size_18sp" /> <textview android:id="@+id/organization_in_my" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="bbbbbbbbbbbbbbbbb" android:layout_below="@+id/name_in_my" android:layout_toendof="@+id/pic_in_my" android:textsize="@dimen/font_size_12sp" android:textcolor="@color/font_white" /> </relativelayout>
this result:
i want string bbbbbbbbb
below string aaaaaa
, it's not right.
and deleted android:layout_centerinparent="true"
in first textview
no changes.
is android:layout_below="@+id/name_in_my"
useless when first view
uses android:layout_centerinparent="true"
i want know why?
to answer question, "how use layout_below in relativelayout?", check example:
<button android:id="@+id/b1" .... /> <button android:id="@+id/b2" android:layout_below="@id/b1" .... />
this means want button b2
below b1
. note used @id
instead of @+id
because added id b1
in declaration of button b1
, thus, there no reason add again.
since want bbbbb
below aaaa
, have put layout_below="id of aaaa"
in bbbb
.
android:layout_centerinparent
means want view @ center of parent, in case whole relative layout.
Comments
Post a Comment