Launcher的hotseat客户要求添加一些指定应用图标。
首先打开机器将要布局的图标手动移动到hotseat位置上面。
然后使用adb命令将data/data/com.android.launcher3/databases这个文件pull出来。这个文件夹是Luancher的数据库文件。里面保存了相关应用的图标信息。
使用SQLiteStudio工具打开pull出来的db文件。打开Tables下的表格就可以看到图标信息了。
打开Launcher3\res\xml\default_workspace_*x*.xml默认布局xml文件,看看有没有包含的hostseat布局,没有就添加一个,我这边是没有的,添加下面应用一个独立的hostseat布局文件:
<include launcher:workspace="@xml/dw_tablet_hotseat" />
然后同目录下创建dw_tablet_hotseat.xml。里面的一个resolve节点对应一个图标。如录音机图标:
<resolve
launcher:container="-101"
launcher:screen="0"
launcher:x="0"
launcher:y="0" >
<favorite
launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.soundrecorder/.SoundRecorder;end" />
</resolve>
launcher:container="-101"代表唯一hotseat位置。
launcher:screen="0"表示第一格,下一个图标递增。
launcher:x="0"表示x坐标,其他的图标递增。
launcher:y="0"表示y坐标,后续的y坐标也是0。
<favorite
launcher:uri= 后面填应用的intent信息,数据库里面复制出来就可以了。
完整的dw_tablet_hotseat.xml:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 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-auto/com.android.launcher3">
<!-- Hotseat (We use the screen as the position of the item in the hotseat) -->
<!-- Messaging, Email, Browser, [All Apps], Music, Gallery, Camera -->
<resolve
launcher:container="-101"
launcher:screen="0"
launcher:x="0"
launcher:y="0" >
<favorite
launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.soundrecorder/.SoundRecorder;end" />
</resolve>
<resolve
launcher:container="-101"
launcher:screen="1"
launcher:x="1"
launcher:y="0" >
<favorite
launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.gallery3d/.app.GalleryActivity;end" />
</resolve>
<resolve
launcher:container="-101"
launcher:screen="2"
launcher:x="2"
launcher:y="0" >
<favorite
launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.camera2/com.android.camera.CameraLauncher;end" />
</resolve>
<resolve
launcher:container="-101"
launcher:screen="3"
launcher:x="3"
launcher:y="0" >
<favorite
launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.chrome/com.google.android.apps.chrome.Main;end" />
</resolve>
<resolve
launcher:container="-101"
launcher:screen="4"
launcher:x="4"
launcher:y="0" >
<favorite
launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.deskclock/.DeskClock;end" />
</resolve>
<resolve
launcher:container="-101"
launcher:screen="5"
launcher:x="5"
launcher:y="0" >
<favorite launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.calendar/.AllInOneActivity;end" />
</resolve>
<resolve
launcher:container="-101"
launcher:screen="6"
launcher:x="6"
launcher:y="0" >
<favorite
launcher:uri="#Intent;action=android.intent.action.MAIN;category=android.intent.category.LAUNCHER;launchFlags=0x10200000;component=com.android.music/.MusicBrowserActivity;end" />
</resolve>
</favorites>
添加上面xml后,重新编译升级就可以看到默认的布局了。