Android 7.1.1 Launcher3 去除Quick Search Bar

Android 7.1.1 Launcher3 去除Quick Search Bar
先看看launcher3的主要界面组成 
 
查看Launcher的代码

 private void setupViews() {
 ...
mWorkspace.bindAndInitFirstWorkspaceScreen(null /* recycled qsb */); 这里初始化了第一个屏幕 qsb就是在第一个屏幕
 ...

查看Workspace.bindAndInitFirstWorkspaceScreen 发现这里会去add qsb

  public void bindAndInitFirstWorkspaceScreen(View qsb) {
        if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {
            return;
        }
        // Add the first page
   ...
        // Always add a QSB on the first screen.
        if (qsb == null) {
            // In transposed layout, we add the QSB in the Grid. As workspace does not touch the
            // edges, we do not need a full width QSB.
            qsb = mLauncher.getLayoutInflater().inflate(
                    mLauncher.getDeviceProfile().isVerticalBarLayout()
                            ? R.layout.qsb_container : R.layout.qsb_blocker_view,
                    firstPage, false);
        }
   CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstPage.getCountX(), 1);
        lp.canReorder = false;
        if (!firstPage.addViewToCellLayout(qsb, 0, getEmbeddedQsbId(), lp, true)) {
            Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout");
        }
    }
 ...

这里有个编译开关 FeatureFlags.QSB_ON_FIRST_SCREEN 
QSB_ON_FIRST_SCREEN默认是true,qsb会在第一个屏幕的celllayout里占用位置而且无法移动。此时应用图标是无法拖拽到qsb所在区域的。 


将其置为false后,qsb就不会添加到第一个屏幕的celllayout里也不会占用位置,但是第一个屏幕的QSB还是在的,它就像悬浮在应用图标上一样。

 


到此我们完成了第一步,接下来就是把悬浮的qsb给去掉了 
查看Launcher相关代码

     private void setupViews() {
     ...
        mQsbContainer = mDragLayer.findViewById(mDeviceProfile.isVerticalBarLayout()
                ? R.id.workspace_blocked_row : R.id.qsb_container);
...

这里的 R.id.qsb_container就是悬浮qsb 
详看layout-port 垂直的layout界面里的launcher.xml

        <!-- Keep these behind the workspace so that they are not visible when
             we go into AllApps -->
        <include layout="@layout/page_indicator"
            android:id="@+id/page_indicator" />

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

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

这样的话我们只需要remove这个qsb view就哦科了

     private void setupViews() {
     ...
        mQsbContainer = mDragLayer.findViewById(mDeviceProfile.isVerticalBarLayout()
                ? R.id.workspace_blocked_row : R.id.qsb_container);
        mDragLayer.removeView(mQsbContainer);
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值