Some small details about the layout of android controls

1. Specify the alignment of the child elements of this element relative to it

 

android:gravity="top"

 2. The position of the control itself on the parent layout is set

android:layout_gravity="center"

       layout_gravity seems to only work in LinearLayout, and pay attention to two points:

       The vertical (vertical) LinearLayout layout cannot be centered vertically through the control's Android:layout_gravity="", but can be centered horizontally.

       The horizontal (horizontal) LinearLayout layout cannot be centered horizontally through the control's android:layout_gravity="", but can be centered vertically.

 

3. Use of color when updating control color

tvAnswer1.setTextColor(getResources().getColor(R.color.primary)

 4. layout_margin is to set the extra space for the top, bottom, left and right borders of the view

android:layout_marginTop="100dp"
android:layout_marginBottom="100dp"
android:layout_marginRight="100dp"
android:layout_marginLeft="100dp"

 

 5. android:padding is to set the distance of the content relative to the border of the view

android:paddingBottom="20dp"

 6. One of the methods for textView to achieve underline effect:

<string name="url"><u>yuzhyun.me</u></string>

 Then use this String resource in the textView.

. . . Subsequent updates

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326677829&siteId=291194637