A brief analysis of Android RelativeLayout relative layout properties

  • 2020-05-07 20:23:24
  • OfStack

Some important attributes used by RelativeLayout:

class 1: the attribute value is true or false
android:layout_centerHrizontal horizontal center
android:layout_centerVertical is vertically centered
android:layout_centerInparent is completely centered relative to the parent element
android:layout_alignParentBottom sticks to the bottom edge of the parent element
android:layout_alignParentLeft sticks to the left edge of the parent element
android:layout_alignParentRight sticks to the right edge of the parent element
android:layout_alignParentTop sticks to the top edge of the parent element
android:layout_alignWithParentIfMissing: use the parent element as a reference if the corresponding sibling cannot be found

class 2: the attribute value must be the id reference name "@id/id-name"
android:layout_below is below an element
android:layout_above is above the element
android:layout_toLeftOf is to the left of an element
android:layout_toRightOf is to the right of an element
android:layout_alignTop: the upper edge of this element is aligned with the upper edge of an element
android:layout_alignLeft the left edge of this element is aligned with the left edge of an element
android:layout_alignBottom the bottom edge of this element is aligned with the bottom edge of an element
android:layout_alignRight the right edge of this element is aligned with the right edge of an element

class 3: attribute values are specific pixel values such as 30dip, 40px
android: the distance between layout_marginBottom and the bottom edge of an element
android: the distance between layout_marginLeft and the left edge of an element
android: the distance from the right edge of an element to layout_marginRight
android: the distance from the upper edge of an element to layout_marginTop
EditText android: hint

when EditText is set to null, enter the prompt in the box
android:gravity
android: the gravity attribute is a qualification to the view content. For example, text above one button. You can set the text to the left of view, to the right of text. Take button as an example. android:gravity="right" means button on the right
android:layout_gravity
android:layout_gravity is used to set the position of view relative to parent view. For example, one button in linearlayout, you want to put the button on the left, on the right, etc. Taking button as an example, android:layout_gravity="right" button is to the right
android:layout_alignParentRight

Causes the right end of the current control to align with the right end of the parent control. Here the attribute value can only be true or false, the default is false.
android: scaleType:
android:scaleType controls how the image resized/moved comes to size on ImageView. ImageView.ScaleType/android:scaleType
CENTER /center is shown in the center of the original size image. When the length/width of the image exceeds that of View, the center part of the image is captured
CENTER_CROP/centerCrop scale up the size of the image so that the length (width) of the image is equal to or greater than the length (width) of View
CENTER_INSIDE/centerInside shows the full contents of the image in the center, making the length/width of the image equal to or less than the length/width of View by scaling down or the original size
FIT_CENTER/fitCenter scale up/down the image to the width of View, centered
FIT_END/fitEnd scale up/down the image to the width of View and display it in the lower part of View
FIT_START/fitStart scale up/down the image to the width of View and display it in the upper part of View
FIT_XY/fitXY  does not scale up/down to the picture at View the size of the display
MATRIX/matrix is drawn using a matrix, dynamically zooming in on the image to display.
** note 1 that the names of images in the Drawable folder cannot be capitalized.

Related articles: