Android Optimization-UI optimization (1), android ui Optimization
Optimize layout level 1. Avoid layout mosaic depth (as shown below)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <LinearLayout android:id="@+id/main_ll_duoyu" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_horizontal" android:layout_gravity="center_vertical" > <TextView android:text="@string/hello_world" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> </LinearLayout></LinearLayout>
We can remove the id as follows:main_ll_duoyu
The LinearLayout of can also achieve the desired effect (the effect is as follows)
2. Use tools to view the Layout
Sdk \ tools \ hierarchyviewer. bat | double-click to open
Now we have removedmain_ll_duoyu
This LinearLayout of, we have a lower layer than the first two and the most, here is just an example, these tools provided by google can help us optimize the app and increase the smoothness of user experience.
3. default maximum layout depth
The default layout depth for android is 10.