当前位置: 代码迷 >> Android >> android Launcher主菜单的每一屏修改为x*x的格局
  详细解决方案

android Launcher主菜单的每一屏修改为x*x的格局

热度:77   发布时间:2016-04-28 03:34:58.0
android Launcher主菜单的每一屏修改为x*x的布局
修改Launcher2/res/value/Dimens.xml 中apps_customize_cell_width 和apps_customize_cell_height的大小。多大的值合适,需要结合代码。
 
PagedViewCellLayout 中estimateCellHSpan和estimateCellVSpan获取返回值n(n就是每屏单元格数目的列和行)。
 
以estimateCellVSpan为例,int n = Math.max(1,(availHeight + mHeightGap)/(mCellHeight + mHeightGap));
 
availHeight 是可用高度,availHeight = estimateCellVSpan's height - topPadding - bottomPadding,而estimateCellVSpan's height = screen‘s heightheight - statusbar's height - navigationBar's height - topPadding - bottomPadding,具体与项目有关;
mHeightGap 通常是-1,不过还是要结合代码逻辑确认;
mCellHeight就是 apps_customize_cell_width乘以系统dimens 后的值
所以就是通过其他已知数据,计算出mCellHeight的值,然后用mCellHeight除以系统dimens得到的结果,就是在xml中apps_customize_cell_width的值。
estimateCellVSpan 类似
  相关解决方案