Android launcher source code explanation 01: Ui layout details 1

Source: Internet
Author: User

This series of articles will start the android lancher source code analysis. The example is the launcher3 source code that comes with Android 2.3. Its: http://download.csdn.net/detail/xianming01/4383598

This is the first article to introduce lancher's UI layout.

1. Layout

Run the APK and the execution result is:

After pressing the Home key:

2. layout files

Let's take a look at the layout file launcher. xml of lancher. Its source code is:

<com.android.launcher3.DragLayer    xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher3"    android:id="@+id/drag_layer"    android:layout_width="match_parent"    android:layout_height="match_parent">    <include layout="@layout/all_apps" />    <!-- The workspace contains 3 screens of cells -->    <com.android.launcher3.Workspace        android:id="@+id/workspace"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:scrollbars="horizontal"        android:fadeScrollbars="true"        launcher:defaultScreen="2">        <include android:id="@+id/cell1" layout="@layout/workspace_screen" />        <include android:id="@+id/cell2" layout="@layout/workspace_screen" />        <include android:id="@+id/cell3" layout="@layout/workspace_screen" />        <include android:id="@+id/cell4" layout="@layout/workspace_screen" />        <include android:id="@+id/cell5" layout="@layout/workspace_screen" />    </com.android.launcher3.Workspace>    <com.android.launcher3.ClippedImageView        android:id="@+id/previous_screen"        android:layout_width="93dip"        android:layout_height="@dimen/button_bar_height"        android:layout_gravity="bottom|left"        android:layout_marginLeft="6dip"        android:scaleType="center"        android:src="@drawable/home_arrows_left"                android:onClick="previousScreen"        launcher:ignoreZone="56dip"        android:focusable="true"        android:clickable="true" />    <com.android.launcher3.ClippedImageView        android:id="@+id/next_screen"        android:layout_width="93dip"        android:layout_height="@dimen/button_bar_height"        android:layout_gravity="bottom|right"        android:layout_marginRight="6dip"        android:scaleType="center"        android:src="@drawable/home_arrows_right"                android:onClick="nextScreen"                launcher:ignoreZone="-56dip"                android:focusable="true"        android:clickable="true" />    <com.android.launcher3.DeleteZone        android:id="@+id/delete_zone"        android:layout_width="@dimen/delete_zone_size"        android:layout_height="@dimen/delete_zone_size"        android:paddingLeft="@dimen/delete_zone_padding"        android:layout_marginBottom="@dimen/half_status_bar_height"        android:layout_gravity="right|center_vertical"        android:scaleType="center"        android:src="@drawable/delete_zone_selector"        android:visibility="invisible"        launcher:direction="vertical"        />    <RelativeLayout        android:id="@+id/all_apps_button_cluster"        android:layout_height="fill_parent"        android:layout_width="@dimen/button_bar_height_portrait"        android:layout_gravity="right|center_vertical"        android:layout_marginBottom="@dimen/half_status_bar_height"        >        <com.android.launcher3.HandleView            style="@style/HotseatButton"            android:id="@+id/all_apps_button"            android:layout_centerVertical="true"            android:layout_alignParentRight="true"            android:src="@drawable/all_apps_button"            launcher:direction="vertical"            />        <ImageView            android:id="@+id/hotseat_left"            style="@style/HotseatButton.Left"            android:layout_below="@id/all_apps_button"            android:src="@drawable/hotseat_phone"            android:onClick="launchHotSeat"            />        <ImageView            android:id="@+id/hotseat_right"            style="@style/HotseatButton.Right"            android:layout_above="@id/all_apps_button"            android:src="@drawable/hotseat_browser"            android:onClick="launchHotSeat"            />    </RelativeLayout></com.android.launcher3.DragLayer>

3. layout File Analysis

For each part, the image is as follows:

  • The first-level UI of launcher is draglayer.
  • Draglayer has several children, the most important of which is workplace and all1_2d as follows:
  • Workplace has five children, each of which is a celllayout
Put widgets and application shortcuts in each celllayout (bubbletextview)
  • Allcategory 2D displays the list of all applications
Reference: 4. Details about launcher UI Layout

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.