Folder文件夹的排布

基于原生态 launcher3的5.1源代码进行分析。

  1. 通过Hierachy view工具,我们知道,Folder布局是在FolderIcon这个文件中进行的,dispatchDraw()这个是关键的地方,在这里我们先打一个log堆栈出来分析下。
java.lang.Throwable
    at com.android.launcher3.FolderIcon.computePreviewItemDrawingParams(FolderIcon.java:564)
    at com.android.launcher3.FolderIcon.dispatchDraw(FolderIcon.java:645)
    at android.view.View.updateDisplayListIfDirty(View.java:14177)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.View.draw(View.java:14974)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3457)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3244)
    at com.android.launcher3.ShortcutAndWidgetContainer.dispatchDraw(ShortcutAndWidgetContainer.java:93)
    at android.view.View.updateDisplayListIfDirty(View.java:14177)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.View.draw(View.java:14974)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3457)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3244)
    at com.android.launcher3.CellLayout.dispatchDraw(CellLayout.java:518)
    at android.view.View.draw(View.java:15249)
    at android.view.View.updateDisplayListIfDirty(View.java:14182)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.View.draw(View.java:14974)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3457)
    at com.android.launcher3.PagedView.dispatchDraw(PagedView.java:1339)
    at android.view.View.draw(View.java:15249)
    at android.view.View.updateDisplayListIfDirty(View.java:14182)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.View.draw(View.java:14974)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3457)
    at com.android.launcher3.DragLayer.drawChild(DragLayer.java:949)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3244)
    at com.android.launcher3.DragLayer.dispatchDraw(DragLayer.java:915)
    at android.view.View.updateDisplayListIfDirty(View.java:14177)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.View.draw(View.java:14974)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3457)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3244)
    at android.view.View.draw(View.java:15249)
    at android.widget.FrameLayout.draw(FrameLayout.java:598)
    at android.view.View.updateDisplayListIfDirty(View.java:14182)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.View.draw(View.java:14974)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3457)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3244)
    at android.view.View.updateDisplayListIfDirty(View.java:14177)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.View.draw(View.java:14974)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3457)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3244)
    at android.view.View.updateDisplayListIfDirty(View.java:14177)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.View.draw(View.java:14974)
    at android.view.ViewGroup.drawChild(ViewGroup.java:3457)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3244)
    at android.view.View.draw(View.java:15249)
    at android.widget.FrameLayout.draw(FrameLayout.java:598)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2667)
    at android.view.View.updateDisplayListIfDirty(View.java:14182)
    at android.view.View.getDisplayList(View.java:14204)
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:273)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:279)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:318)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2530)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2352)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1982)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5895)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
    at android.view.Choreographer.doCallbacks(Choreographer.java:580)
    at android.view.Choreographer.doFrame(Choreographer.java:550)
    at android.view.Choreographer$Frame
  1. 我们来分析pcomputePreviewDrawingParams()
    在这里进行一些layout前的各个数据的初始化的一个过程。
    private void computePreviewDrawingParams(int drawableSize, int totalSize) {}

所现实的三个小图片大小 :mIntrinsicIconSize=72 ;
Folder文件夹所占用的空间 :mTotalWidth=117 ;
圆形的背景图片大小 :previewSize=90 ;
x坐标 :params.transX = transX;
y坐标 :params.transY = transY;
显示的图标要缩小的比例 :params.scale = totalScale;

params.overlayAlpha = overlayAlpha;
previewPadding=6 ;
mAvailableSpaceInPreview=78 ;
adjustedAvailableSpace=70 ;
unscaledHeight=84 ;
mBaselineIconScale=0.8333333 ;
mBaselineIconSize=60 ;
mMaxPerspectiveShift=10.8

//
3. view的绘制过程
A. draw()
B. onDraw()
C. dispatchDraw()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值