[Android] Android layout optimization <include/> and androidinclude
Reprint please mark: Reproduced in http://www.cnblogs.com/Liuyt-61/p/6602891.html
Bytes -------------------------------------------------------------------------------------------
> Reusable components are extracted and used using the include tag.
Purpose: extract the common components and place them in an xml file separately. Then, use the include label to import them to the public layout.
Effect: Improves the UI production and reuse efficiency, and ensures a more regular and easy-to-maintain UI layout.
Eg: <include layout = "@ layout/common_title"/>
Common_title.xml <? Xml version = "1.0" encoding = "UTF-8"?> <RelativeLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: background = "#000000" android: paddingBottom = "10dp" android: paddingTop = "10dp"> <TextView android: id = "@ + id/re" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_alignParentLeft = "true" android: layout_centerVert Ical = "true" android: layout_marginLeft = "10dp" android: text = "back" android: textColor = "# ffffff" android: textSize = "14sp"/> <TextView android: id = "@ + id/title" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_centerInParent = "true" android: text = "layout optimization" android: textColor = "# ffffff" android: textSize = "18sp"/> <TextView android: id = "@ + id/fun" android: layout_width = "wrap_cont Ent "android: layout_height =" wrap_content "android: layout_alignParentRight =" true "android: layout_centerVertical =" true "android: layout_marginRight =" 10dp "android: text =" function "android: textColor = "# ffffff" android: textSize = "14sp"/> </RelativeLayout> -------------------------------------- main. xml <? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical"> <include layout = "@ layout/common_title"/> </LinearLayout>