1:然后我自己看了一下桌面图标的载入过程:

桌面第一次载入时是默认读取一个xml配置文件,完毕配置工作。这个配置文件在Launcher文件夹下,

路径是:\Launcher\res\xml\default_workspace.xml 。这个XML文件就是刚升级,Launcher第

一次显示的时候,会读取的配置文件。default_workspace。xml里面能够配置APP快捷方式、Widget、Search搜索栏等









launcher里面负责解析default_workspace.xml文件的方法是 LauncherProvider.java里面的loadFavorites方法

LauncherProvider.java里面有loadFavorites()这种方法:

     private int loadFavorites(SQLiteDatabase db, int workspaceResourceId) {

            Intent intent = new Intent(Intent.ACTION_MAIN, null);

            intent.addCategory(Intent.CATEGORY_LAUNCHER);

            ContentValues values = new ContentValues();





            if (LOGD) Log.v(TAG, String.format("Loading favorites from resid=0x%08x", workspaceResourceId));





            PackageManager packageManager = mContext.getPackageManager();

            int i = 0;

            try {

                XmlResourceParser parser = mContext.getResources().getXml(workspaceResourceId);

                AttributeSet attrs = Xml.asAttributeSet(parser);

                beginDocument(parser, TAG_FAVORITES);





                final int depth = parser.getDepth();





                final HashMap<Long, ItemInfo[][]> occupied = new HashMap<Long, ItemInfo[][]>();

                LauncherModel model = LauncherAppState.getInstance().getModel();

                。

                。

                。

                。





            return i;

        }





事实上就是一个分析XML和写入数据库的过程,LauncherProvider.java是整个Launcher的数据来源,

知道这些图标怎样载入出来之后对做屏幕是坏 改动背景大小  行列等都有优点。





















2:Launcher 图标增加默认背景。是主题功能的一个小部分也是必不可少的一部分,以下是我今天整理的一些逻辑和代码,Launcher图标的获取处理是在Utilities.java类里面,

我们能够从里面找到Bitmap createIconBitmap(Drawable icon, Context context) 方法。这种方法就是返回应用图标的。

     static Bitmap createIconBitmap(Bitmap icon, Context context) {

        int textureWidth = sIconTextureWidth;

        int textureHeight = sIconTextureHeight;

        int sourceWidth = icon.getWidth();

        int sourceHeight = icon.getHeight();

        if (sourceWidth > textureWidth && sourceHeight > textureHeight) {

            // Icon is bigger than it should be; clip it (solves the GB->ICS migration case)

            return Bitmap.createBitmap(icon,

                    (sourceWidth - textureWidth) / 2,

                    (sourceHeight - textureHeight) / 2,

                    textureWidth, textureHeight);

        } else if (sourceWidth == textureWidth && sourceHeight == textureHeight) {

            // Icon is the right size, no need to change it

            return icon;

        } else {

            // Icon is too small, render to a larger bitmap

            final Resources resources = context.getResources();

            return createIconBitmap(new BitmapDrawable(resources, icon), context);

        }

    }

  能够在这里改动图标的背景 能够增加  

if (tru{

                Bitmap backBitmap = BitmapFactory.decodeResource(context.getResources(),

                        R.drawable.apical_icon_bg);

                int backWidth = backBitmap.getWidth();

                int backHeight = backBitmap.getHeight();

                if(backWidth != sIconWidth || backHeight != sIconHeight)

                {

                    Matrix matrix = new Matrix();

                    matrix.postScale((float)sIconWidth/backWidth, (float)sIconHeight/backHeight);

                    canvas.drawBitmap(Bitmap.createBitmap(backBitmap, 0, 0, backWidth, backHeight, matrix, true),

.0f, 0.0f, null);

                }else

                {

                    canvas.drawBitmap(backBitmap, 0.0f, 0.0f, null);

                }

            }





直接指定一个图片为图标背景 R.drawable.apical_icon_bg;

android launcher开发之图标背景以及默认配置的更多相关文章

  1. Android应用开发-小巫CSDN博客client之嵌入有米广告

    Android应用开发-小巫CSDN博客client之嵌入有米广告 上一篇博客给大家介绍怎样集成友盟社会化组件,本篇继续带来干货,教大家怎样嵌入广告到应用中去.小巫自称专业对接30年,熟悉各大渠道SD ...

  2. Android NDK开发Hello Word!

    在之前的博客中已经为大家介绍了,如何在win环境下配置DNK程序,本篇我将带大家实现一个简单的Hello jni程序,让大家真正感受一下NDK开发的魅力.这里我们选择使用C+JAVA开发Android ...

  3. Android Launcher分析和修改1——Launcher默认界面配置(default_workspace)

    最近工作都在修改Launcher,所以打算把分析源码和修改源码的过程记录下来,最近会写一些关于Launcher的分析和修改博文.因为我是修改4.0.3的Launcher,所以后面文章里面的Launch ...

  4. [转载] Android Metro风格的Launcher开发系列第一篇

    前言:从毕业到现在已经三年多了,回忆一下这三年基本上没有写过博客,总是觉得忙,没时间写,也觉得写博客没什么大用.但是看到很多大牛们都在写博客,分享自己的东西,所以嘛本着向大牛看齐,分享第一,记录第二的 ...

  5. Android Metro风格的Launcher开发系列第一篇

    前言:从毕业到现在已经三年多了,回忆一下这三年基本上没有写过博客,总是觉得忙,没时间写,也觉得写博客没什么大用.但是看到很多大牛们都在写博客,分享自己的东西,所以嘛本着向大牛看齐,分享第一,记录第二的 ...

  6. Android Metro风格的Launcher开发系列第三篇

    前言: 各位小伙伴,又到了每周更新文章了时候了,本来是周日能发出来呢,这不是赶上清明节吗,女王大人发话了,清明节前两天半陪她玩,只留给我周一下午半天时间写博客,哪里有女王哪里就有压迫呀有木有!好了闲话 ...

  7. 【转载】Android Metro风格的Launcher开发系列第二篇

    前言: 各位小伙伴们请原谅我隔了这么久才开始写这一系列的第二篇博客,没办法忙新产品发布,好了废话不说了,先回顾一下:在我的上一篇博客Android Metro风格的Launcher开发系列第一篇写了如 ...

  8. Android开发,使用背景图(xml drawable)为view 设置边框

    Android 开发中,遇到需要设置边框的情景,使用背景图来实现,代码如下: <layer-list xmlns:android="http://schemas.android.com ...

  9. Android Launcher分析和修改11——自定义分页指示器(paged_view_indicator)

    Android4.0的Launcher自带了一个简单的分页指示器,就是Hotseat上面那个线段,这个本质上是一个ImageView利用.9.png图片做,效果实在是不太美观,用测试人员的话,太丑了. ...

随机推荐

  1. PHPCMS V9.3.2用户注册模板中的一个低级Bug

    当我们下载了目前最新的PHPCMS的时候,如果我们修改了用户注册的模板,那么模板缓存就会更新,这时候就会如下 的问题: Parse error: syntax error, unexpected T_ ...

  2. php5.5 + apache2.4 安装配置

    php5.5 做了大量的更新,在与apache搭配的时候如何选择也很有讲究,这里我们以64位 php5.6 和 Apache2.4为例介绍如何配置. 工具/原料 Win7/8 64位 php5.5.6 ...

  3. iOS 开发 Message Digest Algorithm 5(MD5加密)

    MD5的全称是Message Digest Algorithm 5(消息摘要算法第五版),是计算机安全领域广泛使用的一种散列函数,用以提供消息的完整性保护.在90年代初由MIT Laboratory ...

  4. ViewPager+View实现Tab

    注:源码来自慕课网. 使用ViewPager+View实现Tab底部导航: 主要思想:顶部top.xml,中间ViewPager,底部线性布局Tab导航. top.xml具体实现: <?xml ...

  5. c++,给常成员变量赋值

    C++中,常成员变量只能在构造函数赋值,且只能通过参数列表的形式赋值,且必须在构造函数赋值. (拥有常成员变量的类的构造函数必须对所有成员变量赋值.) #include <iostream> ...

  6. 使用SourceTree Push 出现 POST git-receive-pack (chunked) 的解决方法

    在使用SourceTree上传资料的时候,遇到 POST git-receive-pack (chunked) 从 stackoverflow 看到这样一则 This is a bug in Git; ...

  7. 【集训笔记】母函数【母函数模板】【HDOJ1028【HDOJ1085

    以下资料摘自 http://www.cnblogs.com/wally/archive/2012/07/13/hdu1028_1085_1171_.html 生成函数是说,构造这么一个多项式函数g(x ...

  8. 多玩YY聊天记录解析全过程

    再来一发,现在开始! 下载安装YY,观察YY目录,很明显的发现了sqlite3.dll,这个数据库很多很多很多软件都在用,简单小巧且开源.删除sqlite3.dll 进入YY,历史记录不能正常显示,基 ...

  9. zk leader选举自动完成

    server 1: [root@wx03 bin]# ./zkServer.sh status ZooKeeper JMX enabled by default Using config: /zook ...

  10. 基于visual Studio2013解决算法导论之029二叉搜索树

     题目 二叉搜索树 解决代码及点评 #include <stdio.h> #include <malloc.h> #include <stdlib.h> ty ...