Relatively layout is not familiar with Web development. We often use these similar relative la s when using CSS + DIV. When setting the position of a DIV, we often use a DIV as a reference to set the position. If you don't talk about it, you can directly look at the attribute to view the instance.
Attribute name
Description
Android: layout_below
Placed under the specified component
Android: layout_toLeftOf
Placed on the left of the specified component
Android: layout_toRightOf
Placed on the right of the specified component
Android: layout_alignTop
Alignment with specified components as reference
Android: layout_algnBottom
Bottom alignment with specified component as reference
Android: layout_alignLeft
Align left with specified components as reference
Android: layout_alignRight
To specify Components
The preceding example shows how to implement relative layout.
<? Xml version = "1.0" encoding = "UTF-8"?>
<RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "vertical" android: layout_width = "fill_parent"
Android: layout_height = "wrap_content">
<EditText android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" android: layout_alignParentTop = "true"
Android: layout_alignParentRight = "true" android: layout_toRightOf = "@ + id/TV _username"
Android: id = "@ + id/txt_username">
</EditText>
<EditText android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" android: layout_below = "@ + id/txt_username"
Android: layout_alignLeft = "@ + id/txt_username"
Android: layout_alignParentRight = "true" android: id = "@ + id/txt_password"> </EditText>
<TextView android: id = "@ + id/TV _username" android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" android: text = "User Name"
Android: layout_alignParentTop = "true" android: layout_alignParentLeft = "true"
Android: layout_marginTop = "14dp"> </TextView>
<Button android: text = "login" android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" android: layout_below = "@ + id/txt_password"
Android: layout_alignParentRight = "true" android: layout_alignLeft = "@ + id/txt_password"
Android: id = "@ + id/btn_login"> </Button>
<Button android: text = "cancel" android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" android: layout_below = "@ + id/txt_password"
Android: layout_alignRight = "@ + id/TV _username" android: id = "@ + id/btn_cacel"> </Button>
<TextView android: id = "@ + id/TV _password" android: layout_width = "wrap_content"
Android: layout_height = "wrap_content" android: text = "User Password"
Android: layout_centerVertical = "true" android: layout_toLeftOf = "@ + id/txt_password"> </TextView>
</RelativeLayout>
Instance effect:
From jiahui524 Column