一 達成任務:
Launcher界面下Google檔案夾修改背景,應用間的間寬尺寸資源等資訊以及google檔案夾中各個應用的大小調整~
二 主要的布局檔案
1. res/layout/user_folder.xml:布局檔案,用來修改背景等資訊的
2. res/values/colors.xml:顔色等資源設定
+ <color name="quantum_panel_transparent_bg_text_color">#EED8AE</color>
3. res/values/styles.xml
<style name="Icon.AllApps">
<item name="android:background">@null</item>
- <item name="android:textColor">@color/quantum_panel_text_color</item>
+ <item name="android:textColor">@color/quantum_panel_transparent_bg_text_color</item>
<style name="Icon.Folder">
<item name="android:background">@null</item>
- <item name="android:textColor">@color/quantum_panel_text_color</item>
+ <item name="android:textColor">@color/quantum_panel_transparent_bg_text_color</item>
<item name="android:shadowRadius">0</item>
<item name="customShadows">false</item>
.left, 0,
- padding.right, 0);
+ getResources().getDrawable(R.drawable.apps_menu_background), 0, 0,
+ 0, 0);
Rect bgPadding = new Rect()
三 涉及的類檔案:
1. packages/apps/Launcher3/src/android/DeviceProfile.java
// Folder
folderCellWidthPx = cellWidthPx + 3 * edgeMarginPx;
if(SystemProperties.is_lax_tel_mx()) {
folderCellHeightPx = cellHeightPx + edgeMarginPx+40;
} else {
folderCellHeightPx = cellHeightPx + edgeMarginPx;
}
folderBackgroundOffset = -edgeMarginPx;
folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset;
2. src/com/android/launcher3/DeviceProfile.java
主要内容:Icon的尺寸,hotSeat的大小及個數、Icon間的高度和寬度值、Icon的行數和列數、預設的layout等資訊
主要修改了updateIconSize()函數中的方法;
3. src/com/android/launcher3/allapps/AllAppsContainerView.java
public class AllAppsContainerView extends BaseContainerView implements DragSourc
// TODO: Use quantum_panel instead of quantum_panel_shape
InsetDrawable background = new InsetDrawable(
- getResources().getDrawable(R.drawable.quantum_panel_shape), paddin g
四 針對布局檔案Launcher.xml的分析
<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
android:id="@+id/drag_layer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- 桌面的分隔線,将hotseat和workspace分割開來 -->
<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"
android:layout_gravity="bottom" />
<!-- 桌面分隔線上的訓示條,workspace翻頁的時候會顯示 -->
<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" />
<!--手機桌面,預設系統是包含可翻轉5頁 -->
<com.android.launcher2.Workspace
android:id="@+id/workspace"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="@dimen/workspace_left_padding"
android:paddingEnd="@dimen/workspace_right_padding"
android:paddingTop="@dimen/workspace_top_padding"
android:paddingBottom="@dimen/workspace_bottom_padding"
launcher:defaultScreen="2"
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">
<!--workspace總共可翻轉5個頁面,一個workspace_screen定義一個頁面布局 -->
<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.launcher2.Workspace>
<!--hotseat為桌面分隔線下的界面,不随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" />
<!--qsb_bar布局包含桌面上的可搜尋框,以及長按桌面上圖示時顯示删除和應用資訊的操作框 -->
<include
android:id="@+id/qsb_bar"
layout="@layout/qsb_bar" />
<!-- workspace_cling手機剛開機或者對launcher應用清空資料第一次進入到workspace時彈出的操作介紹界面 -->
<include layout="@layout/workspace_cling"
android:id="@+id/workspace_cling"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<!--folder_cling手機剛開始或者對launcher應用清空資料,第一次打開将workspace上兩個以上的圖示拖到一起形成檔案夾時彈出的操作界面 -->
<include layout="@layout/folder_cling"
android:id="@+id/folder_cling"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<!-- voice_button_proxy音量按鍵。。。。 -->
<com.android.launcher2.DrawableStateProxyView
android:id="@+id/voice_button_proxy"
android:layout_width="80dp"
android:layout_height="@dimen/qsb_bar_height"
android:layout_gravity="top|end"
android:clickable="true"
android:onClick="onClickVoiceButton"
android:importantForAccessibility="no"
launcher:sourceViewId="@+id/voice_button" />
<!-- apps_customize_pane點選hotseat中心圖示進入的界面,該界面顯示所用應用和小部件(widget) -->
<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>