Launcher2折腾之路(1)
来源:互联网 发布:林白的过程解析知乎 编辑:程序博客网 时间:2024/06/05 08:41
想自己写一个Launcher,但无从下手,那就从Launcher2源码开刀吧。一味的看源码也不是个事,那就自己动手折腾,修改Launcher来加深对Launcher的理解。
1,把work_space中的cell默认是5个,要整成1个。我的屏幕的size是720P-50hz,对应的Layout文件夹是layout-sw720dp/。我也不知道怎么对应上的,一个一个试的。——!!!
1 - static final int SCREEN_COUNT = 5; 2 - static final int DEFAULT_SCREEN = 2; 3 + static final int SCREEN_COUNT = 1;//5; 4 + static final int DEFAULT_SCREEN =0;// 2; 5 WorkSpace.Java
1 --- a/res/layout-sw720dp/launcher.xml 2 +++ b/res/layout-sw720dp/launcher.xml 3 @@ -57,7 +57,7 @@ 4 android:paddingEnd="@dimen/workspace_right_padding" 5 android:paddingTop="@dimen/workspace_top_padding" 6 android:paddingBottom="@dimen/workspace_bottom_padding" 7 - launcher:defaultScreen="2" 8 + launcher:defaultScreen="0" 9 launcher:cellCountX="@integer/cell_count_x" 10 launcher:cellCountY="@integer/cell_count_y" 11 launcher:pageSpacing="@dimen/workspace_page_spacing" 12 @@ -65,10 +65,10 @@ 13 launcher:scrollIndicatorPaddingRight="@dimen/workspace_divider_padding_right"> 14 15 <include android:id="@+id/cell1" layout="@layout/workspace_screen" /> 16 - <include android:id="@+id/cell2" layout="@layout/workspace_screen" /> 17 + <!-- <include android:id="@+id/cell2" layout="@layout/workspace_screen" /> 18 <include android:id="@+id/cell3" layout="@layout/workspace_screen" /> 19 <include android:id="@+id/cell4" layout="@layout/workspace_screen" /> 20 - <include android:id="@+id/cell5" layout="@layout/workspace_screen" /> 21 + <include android:id="@+id/cell5" layout="@layout/workspace_screen" /> --> 22 </com.android.launcher2.Workspace> 23
2,APPS_CUSTOMIZE界面的Icon后面加背景图片
1 if (true) 2 { 3 Bitmap backBitmap = BitmapFactory.decodeResource(context.getResources(), 4 R.drawable. icon_back); 5 int backWidth = backBitmap.getWidth(); 6 int backHeight = backBitmap.getHeight(); 7 Log. i(Launcher.TAG,"koffu pic width=" + backWidth + ", width=" + backHeight); 8 Log. i(Launcher .TAG ,"koffu sIconwidth=" + sIconWidth + ", sIconHeight=" + sIconHeight); 9 if(backWidth != sIconWidth || backHeight != sIconHeight) 10 { 11 Matrix matrix = new Matrix(); 12 matrix.postScale((float)sIconWidth /backWidth, (float)sIconHeight /backHeight); 13 canvas.drawBitmap(Bitmap.createBitmap(backBitmap, 0, 0, backWidth, backHeight, matrix, true ), 14 0.0f, 0.0f, null); 15 } else 16 { 17 canvas.drawBitmap(backBitmap, 0.0f, 0.0f, null); 18 } 19 } 20
效果如下(每个icon后面都有一个熊孩子图片):
稍微延伸一下:
Canvas/Bitmap/Matrix这三个类的关系
Bitmap这个类主要是用来“获取”“承装”位置的类
Canvas这个类主要是用来“绘制”位图的类
Matrix这个类主要是用来“缩放”“旋转”的类
具体可以参考:http://www.cnblogs.com/feisky/archive/2010/01/10/1643460.html
0 0
- Launcher2折腾之路(1)
- Launcher2折腾之路(2)
- Launcher2折腾之路(3)
- Launcher2折腾之路(4)
- ubuntu 折腾之路
- sublime折腾之路
- 折腾wordpress之路
- Android4.1标准桌面应用(Launcher2)分析之Android.mk
- Android4.1标准桌面应用(Launcher2)分析之Android.mk
- launcher2
- launcher2
- Android Launcher2之页面滑动
- 开启YII2折腾之路:玩弄
- 5 开启Yii2折腾之路:玩弄
- Launcher2的桌面预设【1】
- 折腾开源WRT的AC无线路由之路-1
- 折腾之SDC文件
- 折腾之重装linux
- 一切皆为 JavaScript
- 让他特地让他感受为日粉色的色的人体
- vs2010项目打包
- 从ramdisk根文件系统启动Linux成功,及使用initramfs启动linux
- VC编程(1)Socket网络编程 连接邮箱服务器+授时服务器
- Launcher2折腾之路(1)
- DSBase要解决的问题
- 对 spring 与 EJB 的理解
- 2012-Linux->19(Linux-2.6.32.2内核在mini2440上的移植---根文件系统制作)
- fifa coins FtO9W 9oNNn 90Y6K
- keilc error C183: unmodifiable lvalue
- UVA - 10944 Nuts for nuts 状态压缩DP
- String&Charactter
- fifa coins online dfqUc eXv4p SOIHY