【源码剖析】Launcher 8.0 源码 (11) --- Launcher 启动流程 第五步之细化布局具体参数

本文详细剖析了Android Launcher8.0启动流程的第五步,即UI子模块的布局规划,包括搜索栏、工作区、热座、页码指示器和Overview模式的布局参数设置。同时讨论了不同布局的区别,如搜索栏的位置和高度,以及如何根据壁纸颜色调整系统颜色。
摘要由CSDN通过智能技术生成

Launcher8.0启动流程的第五步,UI子模块的细节规划,各个模块的大小,真正的尺寸等等。这一步是采用第一步获取的方案,把第四步的模块细节进行完成。

 

在onCreate方法中,其源码如下:

 mDeviceProfile.layout(this, false /* notifyListeners */);


    mExtractedColors = new ExtractedColors();
    loadExtractedColorsAndColorItems();
    mPopupDataProvider = new PopupDataProvider(this);
    ((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE))
            .addAccessibilityStateChangeListener(this);

    lockAllApps();
    restoreState(savedInstanceState);
    if (LauncherAppState.PROFILE_STARTUP) {
        Trace.endSection();
    }
    int currentScreen = PagedView.INVALID_RESTORE_PAGE;
    if (savedInstanceState != null) {
        currentScreen = savedInstanceState.getInt(RUNTIME_STATE_CURRENT_SCREEN, currentScreen);
    }

 

其中最复杂的是mDeviceProfile.layout(this, false /* notifyListeners */)方法。

该方法源码中一共有6个注释

// Layout the search bar space

// Layout the workspace

// Only display when enabled

// Layout the hotseat

// Layout the page indicators

// Layout the Overview Mode

也就是layout方法一共做了6件事情可分为6小步分析,方便记忆和理解。

 

layout的第1小步,创建google快捷搜索栏的位置。

// Layout the search bar space
    Point searchBarBounds = getSearchBarDimensForWidgetOpts();
    View searchBar = launcher.getDropTargetBar();
    lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
    lp.width = searchBarBounds.x;
    lp.height = searchBarBounds.y;
    lp.topMargin = mInsets.top + edgeMarginPx;
    searchBar.setLayoutParams(lp);

 

原生手机是集成了google应用,其中就会提供一个google搜索的widget,这个widget我们能在手

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值