Android optimized--ui optimization (i)

Source: Internet
Author: User

Optimize the layout hierarchy 1. Avoid layout tessellation too deep (see 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 completely remove the ID: main_ll_duoyu This linearlayout can also achieve the effect we want (the effect is as follows)

2. Use tools to view layouts
    • Tool Path

Sdk\tools\hierarchyviewer.bat | Double-click Open

    • View layout Comparison


We have now removed main_ll_duoyu this linearlayout, we are a little bit less than the first two graphs and the most one, here is just an example, you can use these tools provided by Google to help us optimize the app, to increase the flow of user experience

3. Default maximum layout depth

Android default to the layout depth of 10

Android optimized--ui optimization (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.