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

Source: Internet
Author: User

Android Optimization-UI optimization (2), android ui Optimization
UseincludeTag reuse Layout-1.includeFunctions of tags

What should I do if I use this layout on many interfaces? If every page is written, the code is too redundant and the maintenance difficulty increases.

<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 "android: orientation =" vertical "> <include layout =" @ layout/activity_clude_item "/> <TextView android: layout_width =" match_parent "android: layout_height =" match_parent "android: gravity = "center" android: text = "this is something in the middle"/> </LinearLayout>

I will use this layout aboveincludeLabels, code is obviously more neat, and the layout is more reusable, reducing the memory usage of the app

-2. includeTag usage
<include layout="@layout/activity_clude_item"/>

We uselayout="@layout/activity_clude_item"Set reusable layout files

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.