Android advanced UI and androidui
Introduction
There is a document on UI Optimization on the official Android website, and developers need to master it.
1. Abstract Layout
<Include/> labels can reuse layout files
<include layout="@layout/titlebar"/>
<Merge/> labels can delete redundant layers. They are mostly used to replace FrameLayout or remove redundant view groups in a view hierarchy when one layout contains another.
<merge xmlns:android="http://schemas.android.com/apk/res/android"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/add"/> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/delete"/> </merge>
<ViewStub/> the advantage of using a tag is that it is loaded only when needed, and does not affect the UI initialization performance. You can use the <ViewStub/> label for various infrequent la s to reduce memory usage and accelerate rendering.
<ViewStub android:id="@+id/stub_import" android:inflatedId="@+id/panel_import" android:layout="@layout/progress_overlay" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" />
2. Android styles and themes
The style in android is used to define the display style for the interface elements. It is a set of one or more view control attributes.
Android allows you to define the Look and Feel of an Android Application in an external style file. You can apply the defined style to different Views. You can define styles in an XML file and apply these styles to different components. To use XML to define styles, you only need to configure some common attributes. If you need to modify styles in the future, you can modify them in a centralized manner.
You can create an XML file under the/res/values file of your Android project. Note that the root directory of the file must be <resources>. The following example shows how to create a style. xml file in the/res/xml directory.
The definition and usage are as follows:
<? Xml version = "1.0" encoding = "UTF-8"?> <Resources> <style name = "itcast"> <! -- Define a globally unique name for the style --> <item name = "android: textSize"> 18px </item> <! -- The name attribute is the attribute to be held by the View control of the style --> <item name = "android: textColor" >#0000cc </item> </style> </resources>
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" .> <TextView style="@style/itcast" .. /></LinearLayout>
You can edit AndroidManifest. xml to set a style for all the activities in the application or for a specific Activity.
A topic is a style applied to the entire Activity or application compared to a single view. The following example defines a theme that inherits the theme defined by Android.
The definition and usage are as follows:
<activity android:theme="@style/wrap_content">
<activity android:theme="@android:style/Theme.Dialog">
3. ViewFlipper
What is its function? It is a simple ViewAnimator that adds the View to ViewFlipper to form an animation. However, only one View is displayed at a time point. Of course, you can also set automatic and regular display of the animation.
4. Fragment framework
What is Fragment? Fragment is a clip that is parasitic in the context of an Activity. Fragment has a view hierarchy related to it and has a lifecycle very similar to the Activity.
What is the role of Fragment? Activity has a limitation. You cannot place multiple Activity interfaces on the screen and display them. Therefore, Fragment is created to make up for the limitations of the Activity. Fragment can respond to Activity-like functions like the Back key like Activity.
Fragment Lifecycle
Advanced tutorial on Android UI design
Developer.android.com/design/index.html
What are the better advanced books for learning android UI? Recommended
There are more and more books about Android. However, there are few books on the UI. I tried to find it. We recommend that you read the Android advanced tutorial. There is a lot of information here about Android UI. A beginner Android programmer will have a lot of GAINS. Hope you can help.