Share some Android layout design learning experience

Point 1: When creating a layout page, the id of each control should be properly named, and multiple words should be separated by _

Control abbreviation LinearLayout LL RelativeLayout RL ConstraintLayout CL ListView LV ScollView SV TextView TV Button BTN ImageView IV  CheckBox cb RadioButton rb EditText etCopy the code

Point 2: TextView uses “wrap_content” in preference

android:layout_width="wrap_content"
android:layout_height="wrap_content"
Copy the code

Tip 3: When setting colors, try to set transparency, for example

#ff333333
android:textColor="@color/black_ff333333"
Copy the code

It is recommended to create a shape. XML file under drawable with the following contents

<? The XML version = "1.0" encoding = "utf-8"? > <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="30dp"/> <solid android:color="#FFE6E6FA"/> <padding android:bottom="5dp" android:top="5dp" android:left="10dp" android:right="10dp"/> </shape>Copy the code

5. Create drawable -xxxhdPI file in the res folder to save the image file, and name the image in. PNG,. Webp and

Tip 6: When setting the style, you are advised to use Alt + Enter to bring up the resource box

Insert small symbol method:

Step: Right-click on drawable — new — Vector Asset — click on Clip Art to select the symbol you want and enter the reference code in the desired control, for example

android:drawableRight="@drawable/ic_baseline_chevron_right_24"
Copy the code