launcher学习

luancher的主布局文件:launcher.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<!-- Full screen view projects under the status bar and contains the background -->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"

    android:id="@+id/launcher"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/workspace_bg">

    <com.android.launcher2.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:background="@drawable/workspace_bg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <!-- Keep these behind the workspace so that they are not visible when
             we go into AllApps -->
        <include
            android:id="@+id/dock_divider"
            layout="@layout/workspace_divider"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/button_bar_height_plus_padding"
            android:layout_gravity="bottom|center_horizontal" />

        <include
            android:id="@+id/paged_view_indicator"
            layout="@layout/scroll_indicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_marginBottom="@dimen/button_bar_height_plus_padding" />

        <!-- The workspace contains 5 screens of cells 工作空间-->
        <com.android.launcher2.Workspace   
            android:id="@+id/workspace"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingLeft="@dimen/workspace_left_padding"
            android:paddingRight="@dimen/workspace_right_padding"
            android:paddingTop="@dimen/workspace_top_padding"
            android:paddingBottom="@dimen/workspace_bottom_padding"
            launcher:defaultScreen="3"
            launcher:cellCountX="@integer/cell_count_x"
            launcher:cellCountY="@integer/cell_count_y"
            launcher:pageSpacing="@dimen/workspace_page_spacing"
            launcher:scrollIndicatorPaddingLeft="@dimen/workspace_divider_padding_left"
            launcher:scrollIndicatorPaddingRight="@dimen/workspace_divider_padding_right">

            <include android:id="@+id/cell1" layout="@layout/workspace_screen" />   <!-- 5页-->
            <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.launcher2.Workspace>

        <include layout="@layout/hotseat"<!-- 下方的快捷方式-->
            android:id="@+id/hotseat"
            android:layout_width="match_parent"
            android:layout_height="@dimen/button_bar_height_plus_padding"
            android:layout_gravity="bottom" />

        <include
            android:id="@+id/qsb_bar"
            layout="@layout/qsb_bar" />

        <!-- The Workspace cling must appear under the AppsCustomizePagedView below to ensure
             that it is still visible during the transition to AllApps and doesn't overlay on
             top of that view. -->
        <include layout="@layout/workspace_cling"<!-- 第一次进Home显示-->
            android:id="@+id/workspace_cling"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone" />

        <include layout="@layout/folder_cling"<!-- 第一次进文件夹存储快捷方式显示-->
            android:id="@+id/folder_cling"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="gone" />

        <com.android.launcher2.DrawableStateProxyView
            android:id="@+id/voice_button_proxy"
            android:layout_width="80dp"
            android:layout_height="@dimen/qsb_bar_height"
            android:layout_marginRight="@dimen/qsb_voice_proxy_padding_right"
            android:layout_gravity="top|right"
            android:clickable="true"
            android:onClick="onClickVoiceButton"
            android:importantForAccessibility="no"
            launcher:sourceViewId="@+id/voice_button" />

        <include layout="@layout/apps_customize_pane"<!-- 所有应用界面-->
            android:id="@+id/apps_customize_pane"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="invisible" />
    </com.android.launcher2.DragLayer>
</FrameLayout>

apps_customize_pane.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.launcher2.AppsCustomizeTabHost
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher">
    <LinearLayout
        android:id="@+id/apps_customize_content"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone"
        android:layoutDirection="ltr">
        <!-- The layout_width of the tab bar gets overriden to align the content
             with the text in the tabs in AppsCustomizeTabHost. -->
        <FrameLayout
            android:id="@+id/tabs_container"
            android:layout_width="wrap_content"
            android:layout_height="@dimen/apps_customize_tab_bar_height"
            android:layout_marginTop="@dimen/apps_customize_tab_bar_margin_top"
            android:layout_gravity="center_horizontal">
            <com.android.launcher2.FocusOnlyTabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="left"
                android:background="@drawable/tab_unselected_holo"
                android:tabStripEnabled="false"
                android:divider="@null" />
            <include
                android:id="@+id/market_button"
                layout="@layout/market_button"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="right" />
        </FrameLayout>
        <FrameLayout <!-- 所有应用界面显示-->
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <com.android.launcher2.AppsCustomizePagedView
                android:id="@+id/apps_customize_pane_content"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                launcher:maxAppCellCountX="@integer/apps_customize_maxCellCountX"
                launcher:maxAppCellCountY="@integer/apps_customize_maxCellCountY"
                launcher:pageLayoutWidthGap="@dimen/apps_customize_pageLayoutWidthGap"
                launcher:pageLayoutHeightGap="@dimen/apps_customize_pageLayoutHeightGap"
                launcher:pageLayoutPaddingTop="@dimen/apps_customize_pageLayoutPaddingTop"
                launcher:pageLayoutPaddingBottom="@dimen/apps_customize_pageLayoutPaddingBottom"
                launcher:pageLayoutPaddingLeft="@dimen/apps_customize_pageLayoutPaddingLeft"
                launcher:pageLayoutPaddingRight="@dimen/apps_customize_pageLayoutPaddingRight"
                launcher:widgetCellWidthGap="@dimen/apps_customize_widget_cell_width_gap"
                launcher:widgetCellHeightGap="@dimen/apps_customize_widget_cell_height_gap"
                launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x"
                launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y"
                launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
                launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
                launcher:maxGap="@dimen/workspace_max_gap" />
            <FrameLayout
                android:id="@+id/animation_buffer"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="gone" />

            <include
                android:id="@+id/paged_view_indicator"
                layout="@layout/scroll_indicator"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom" />
        </FrameLayout>
    </LinearLayout>

    <include layout="@layout/all_apps_cling"<!-- 第一次进所以应用界面显示-->
        android:id="@+id/all_apps_cling"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone" />
</com.android.launcher2.AppsCustomizeTabHost>

1、device\rockchip\rk30sdk\overlay\packages\apps\Launcher2\res\xml-sw720dp\default_workspace.xml等同于launcher相应目录下的文件,用来控制开机第一次加载的快捷方式和widage

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<favorites xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher">
    <!-- Far-left screen [0] -->

    <!-- Left screen [1] -->
    <appwidget
        launcher:packageName="com.android.settings"
        launcher:className="com.android.settings.widget.SettingsAppWidgetProvider"
        launcher:screen="1"
        launcher:x="0"
        launcher:y="3"
        launcher:spanX="4"
        launcher:spanY="1" />

    <!-- Middle screen [2] -->
    <appwidget
        launcher:packageName="com.android.deskclock"
        launcher:className="com.android.alarmclock.AnalogAppWidgetProvider"
        launcher:screen="2"
        launcher:x="1"
        launcher:y="0"
        launcher:spanX="2"
        launcher:spanY="2" />
    <favorite
        launcher:packageName="com.android.camera"
        launcher:className="com.android.camera.Camera"
        launcher:screen="2"
        launcher:x="0"
        launcher:y="3" />

    <!-- Right screen [3] -->
    <favorite
        launcher:packageName="com.android.gallery3d"
        launcher:className="com.android.gallery3d.app.Gallery"
        launcher:screen="3"
        launcher:x="1"
        launcher:y="3" />
    <favorite
        launcher:packageName="com.android.settings"
        launcher:className="com.android.settings.Settings"
        launcher:screen="3"
        launcher:x="2"
        launcher:y="3" />

    <!-- Far-right screen [4] -->

    <!-- Hotseat -->
    <favorite
        launcher:packageName="com.android.gallery3d"
        launcher:className="com.android.gallery3d.app.Gallery"
        launcher:container="-101"
        launcher:screen="2"
        launcher:x="2"
        launcher:y="0" />
    <favorite
        launcher:packageName="com.android.browser"
        launcher:className="com.android.browser.BrowserActivity"
        launcher:container="-101"
        launcher:screen="3"
        launcher:x="3"
        launcher:y="0" />
    <favorite
        launcher:packageName="com.android.settings"
        launcher:className="com.android.settings.Settings"
        launcher:container="-101"
        launcher:screen="5"
        launcher:x="5"
        launcher:y="0" />
    <favorite
        launcher:packageName="com.android.music"
        launcher:className="com.android.music.MusicBrowserActivity"
        launcher:container="-101"
        launcher:screen="6"
        launcher:x="6"
        launcher:y="0" />
</favorites>

x ,y 表示相应网格中的位置,screen表示在第几屏,spanx、spany表示widget占的空间


2、packages\apps\Launcher2\res\values-sw720dp\config.xml

cell_count_x 表示一行可以显示多少个快捷方式


3、packages\apps\Launcher2\res\layout-land\launcher.xml

Workspace的defaultScreen表示缺省显示第几屏

4、显示壁纸

packages\apps\Launcher2\res\layout\apps_customize_pane.xml

去掉所有android:background="#FF000000"

另外\packages\apps\Launcher2\src\com\android\launcher2\Launcher.java所有调用updateWallpaperVisibility参数修改为true

还有showAppsCustomizeHelper函数中进行如下调整,要不下面的快捷方式在进入所有应用界面时消失会有延时


5、循环滚屏调整

launcher学习_第1张图片

launcher学习_第2张图片


launcher学习_第3张图片


launcher学习_第4张图片



调节Launch上 快捷方式的间距:

相应资源目录下dimens.xml 中workspace_cell_height_land

你可能感兴趣的:(launcher学习)