Android4.4-Launcher源码分析系列之CellLayout

一.CellLayout是什么

在前面的 Android4.4-Launcher源码分析系列之Launcher介绍分析了Launcher的布局,CellLayout继承自ViewGroup,

一个Workspace由多个CellLayout组成,每一个CellLayout负责里面图标(favorite)和widget的显示.说白了,我们滑动屏幕的每一页就是一个CellLayout.

二、CellLayout的布局

CellLayout的布局为workspace_screen.xml.

<com.android.launcher3.CellLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:hapticFeedbackEnabled="false"      
    launcher:maxGap="@dimen/workspace_max_gap" />

hapticFeedbackEnabled是触力反馈的意思,比如说按一下震动就是触力反馈.

maxGap是CellLayout中元素(图标,widget)之间的最大距离

除了这两个属性其他的属性都是在代码中定义的.

WorkSpace是在insertNewWorkspaceScreen方法中加载CellLayout的布局的.

/**
     * @param  screenId       屏幕Id
     * @param  insertIndex	     插入的序号
     * 插入新的屏幕 
     */
    public long insertNewWorkspaceScreen(long screenId, int insertIndex) {
    	 
    	System.out.println(".............WorkSpace.......增加一页");
    	if (mWorkspaceScreens.containsKey(screenId)) {
            throw new RuntimeException("Screen id " + screenId + " already exists!");
        }
        //加载CellLayout的布局
        CellLayout newScreen = (CellLayout)mLauncher.getLayoutInflater().inflate(R.layout.workspace_s
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值