Android Optimization-UI optimization (1), android ui Optimization

Source: Internet
Author: User

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_duoyuThe LinearLayout of can also achieve the desired effect (the effect is as follows)

2. Use tools to view the Layout
  • Tool Path

Sdk \ tools \ hierarchyviewer. bat | double-click to open

  • View Layout Comparison


Now we have removedmain_ll_duoyuThis 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.

Related Article

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.