Android Launcher View构架浅析

来源:互联网 发布:linux创建用户指定id 编辑:程序博客网 时间:2024/05/22 12:00
 

http://www.linuxidc.com/Linux/2011-02/32399.htm1. 先来看一下launcher activity view的架构图(hierarchyviewer.bat工具获取):

 

 

2. 再来看layout/launcher.xml, layout-port/launcher.xml,  layout-land/launcher.xml


<com.Android.Launcher.DragLayer

    xmlns:Android="http://schemas.android.com/apk/res/android"

    xmlns:launcher="http://schemas.Android.com/apk/res/com.android.Launcher"

    Android:id="@+id/drag_layer"

    Android:layout_width="fill_parent"

    Android:layout_height="fill_parent"

    Android:background="#FFF">

    <!-- The workspace contains 3 screens of cells -->

    <com.Android.Launcher.Workspace

        Android:id="@+id/workspace"

        Android:layout_width="fill_parent"

        Android:layout_height="fill_parent"

        launcher:defaultScreen="1">

        <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" />

    </com.Android.Launcher.Workspace>

    <SlidingDrawer

        Android:id="@+id/drawer"

        Android:layout_width="fill_parent"

        Android:layout_height="fill_parent"

        Android:orientation="horizontal"

        Android:bottomOffset="4dip"

        Android:handle="@+id/all_apps"

        Android:content="@+id/content">

        <com.Android.Launcher.HandleView

            Android:id="@id/all_apps"

            Android:layout_width="56dip"

            Android:layout_height="56dip"

            Android:background="@drawable/handle"

            Android:focusable="true"

            Android:clickable="true"

            Android:scaleType="center"

            Android:src="../../@drawable/handle_icon"

            launcher:direction="vertical" />

        <com.Android.Launcher.AllAppsGridView

            Android:id="@id/content"

            Android:layout_width="fill_parent"

            Android:layout_height="fill_parent"

            launcher:texture="@drawable/pattern_carbon_fiber_dark"

            Android:scrollbarStyle="outsideInset"

            Android:drawSelectorOnTop="false"

            Android:listSelector="@drawable/grid_selector"

            Android:nextFocusLeft="@id/all_apps"

            Android:nextFocusDown="@id/content"

            Android:nextFocusUp="@id/content"

            Android:nextFocusRight="@id/content"

            Android:verticalSpacing="10dip"

            Android:numColumns="5" />

    </SlidingDrawer>

    <com.Android.Launcher.DeleteZone

        Android:id="@+id/delete_zone"

        Android:layout_width="49dip"

        Android:layout_height="wrap_content"

        Android:scaleType="center"

        Android:src="../../@drawable/ic_delete"

        Android:background="@drawable/delete_zone_selector"

        Android:layout_marginBottom="-25dip"

        Android:layout_gravity="right|center_vertical"

        Android:visibility="gone"

        launcher:direction="vertical" />

</com.Android.Launcher.DragLayer>

3. 呈现界面:()

 

其中Workspace可增加到任意多个cell,如7个:

        launcher:defaultScreen="3">

        <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" />

        <include Android:id="@+id/cell6" layout="@layout/workspace_screen" />

        <include Android:id="@+id/cell7" layout="@layout/workspace_screen" />

 

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2011-02/32399.htm

原创粉丝点击