android 如何获取launcher的workspace中的每一个celllayout的位图???
2012-05-24 16:08
316 查看
我要做一个3D旋转桌面,现在已经绘制好立方体,往上面贴好纹理了,不过纹理是其他图片,现在我想要获取launcher的workspace中的每一个celllayout的位图,然后将其作为纹理贴到立方体上。
也就是说,我现在不知道如何将workspace中的每一个分屏view(celllayout)转换成位图。
我已经尝试过的方法有两个,都不行: 注:下面的cell1来自launcher.xml中的<include android:id="@+id/cell1" layout="@layout/workspace_screen" />这一句,具体见层级观察器的截图。
1.
2.
[img=http://img.my.csdn.net/uploads/201205/24/13378284_7309.jpg][/img]
也就是说,我现在不知道如何将workspace中的每一个分屏view(celllayout)转换成位图。
我已经尝试过的方法有两个,都不行: 注:下面的cell1来自launcher.xml中的<include android:id="@+id/cell1" layout="@layout/workspace_screen" />这一句,具体见层级观察器的截图。
1.
View view = findViewById(R.id.cell1); Bitmap bit = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);//这一句话报错,说view的宽高是0. Canvas c = new Canvas(bit); view.draw(c); if(bit==null) Log.v(TAG,"mBitmap is null"); else Log.v(TAG,"mBitmap is not null");
2.
View tempView=(View)findViewById(R.id.cell1); tempView.setDrawingCacheEnabled(true); tempView.measure( MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));//这一句话报错,说tempView大小不确定神马的。 tempView.layout(0, 0, tempView.getMeasuredWidth(),tempView.getMeasuredHeight()); tempView.buildDrawingCache(); mBitmap[0]= tempView.getDrawingCache(); if(mBitmap[0]==null) Log.v(TAG,"mBitmap is null");
[img=http://img.my.csdn.net/uploads/201205/24/13378284_7309.jpg][/img]
相关文章推荐
- android Launcher应用之CellLayout的设计
- Android_launcher中celllayout类简单分析
- 【Android开发技巧】 - 如何获取应用Shortcut在Launcher坐标信息
- 自定义控件如何获取 android:layout_width属性
- Android如何在一个布局(Layout)中获取另一个布局中空间的id
- Android 如何获取一个layout实例
- 如何获取Android app的apk包名和launcherActivity?
- android LinearLayout等view如何获取button效果
- 获取android手机内部存储空间和外部存储空间的参数 && 如何决定一个apk的安装位置
- android中如何在代码中直接设置View的layout_weight属性
- android之LayoutInflater的获取与使用
- 如何获取和设置android系统铃声和音量大小
- Android功能总结:仿照Launcher的Workspace实现左右滑动切换
- .Android如何获取屏幕的分辨率 .
- Android之View的知识(getWidth() 和getMeasuredWidth区别 如何在oncreate获取宽高)
- Android 如何获取应用通知权限
- Android Launcher分析和修改1——Launcher默认界面配置(default_workspace)
- android 中如何获取camera当前状态
- 如何在不同的语言/平台中获取Android ID
- 【ZK学习笔记】点击listcell中的button 如何获取按钮所在的listitem