Android Optimization-UI optimization (2), android ui Optimization
Useinclude
Tag reuse Layout-1.include
Functions 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 aboveinclude
Labels, code is obviously more neat, and the layout is more reusable, reducing the memory usage of the app
-2.
include
Tag usage
<include layout="@layout/activity_clude_item"/>
We uselayout="@layout/activity_clude_item"
Set reusable layout files