android layout properties detail sharing

  • 2020-05-26 10:05:10
  • OfStack

RelativeLayout

Class 1: attribute values are true or false

android:layout_centerHrizontal level is in the middle
android:layout_centerVertical is vertically centered
android:layout_centerInparent is completely centered relative to the parent element
android:layout_alignParentBottom attaches 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 attaches 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 an 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 top edge of this element is aligned with the top 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

Category 3: attribute values are specific pixel values, such as 30dip, 40px

android: the distance from the bottom edge of an element to layout_marginBottom
android: the distance from the left edge of an element to layout_marginLeft
android: the distance from the right edge of an element to layout_marginRight
android: the distance of layout_marginTop from the upper edge of an element


EditText android: hint

Enter the prompt in the box when EditText is set to null.

android: gravity
android: the gravity attribute is a qualification to the view content. For example, text above an button. You can set the text to the left or right of view. Take button for example, android:gravity="right", then the text above button is to the right

android:layout_gravity
android:layout_gravity is used to set the position of view relative to the parent view. For example, if an button is in linearlayout, you can set the button to the left, right, etc. Take 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 property value can only be true or false, the default is false.

android: scaleType:
android:scaleType controls how the image resized/moved comes to size for ImageView.

ImageView.ScaleType/android:scaleType

1) CENTER /center is displayed 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 and displayed

2) CENTER_CROP/centerCrop scale up the size centered display of the image so that the length (width) of the image is equal to or greater than the length (width) of View.

3) CENTER_INSIDE/centerInside completely centers the content of the image, making the length/width of the image equal to or less than the length/width of View by scaling down or the original size

4) FIT_CENTER/fitCenter scale up/down the image to the width of View and display it in the center

5) FIT_END/fitEnd scale up/down the image to the width of View and display it in the lower part of View

6) FIT_START/fitStart scale up/down the image to the width of View and display it in the upper part of View

7 )FIT_XY / fitXY 把图片不按比例扩大/缩小到View的大小显示

8) MATRIX/matrix is drawn with a matrix, dynamically zooming out and zooming in to display.

One thing to note is that the names of images in the Drawable folder cannot be capitalized

However, the "@+id/btn_Click2" property of layout controls such as LinearLayout, RelativeLayout and so on can be capitalized, underlined, etc


Related articles: