Android中将View的内容保存为图像的简单实例
时间:2023-11-01 12:45:41
原理:创建一个新的Bitmap,然后再根据它来创建一个Canvas,最后调用View的draw方法将View画到Canvas上,这样得到的Bitmap就是我们想要的。
代码:
public Bitmap createViewBitmap(View v) {
Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
v.draw(canvas);
return bitmap;
}
标签:Android,View,图像
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
unity实现虚拟摇杆控制Virtual Joystick
2022-09-26 11:56:28
![](https://img.aspxhome.com/file/2023/3/77263_0s.jpg)
B/S与C/S架构的区别介绍
2023-07-02 13:24:33
Android基于OpenCV实现QR二维码检测
2021-12-13 07:56:39
![](https://img.aspxhome.com/file/2023/2/138952_0s.png)
C#实现DVD借出归还管理系统
2021-07-02 06:55:38
Java中Optional类及orElse方法详解
2022-07-12 03:21:36
WPF实现带筛选功能的DataGrid
2022-05-07 07:48:56
![](https://img.aspxhome.com/file/2023/0/76430_0s.png)
深入理解C# 装箱和拆箱(整理篇)
2023-10-04 02:13:13
Unity3D实现物体旋转缩放移动效果
2023-07-17 22:11:58
C#中using指令的几种用法
2022-01-25 01:35:25
Android SharePreferences与数据库SQLite存储实现方法介绍
2023-03-13 11:20:45
![](https://img.aspxhome.com/file/2023/6/120126_0s.png)
Scala数据库连接池的简单实现
2023-07-14 14:19:37
![](https://img.aspxhome.com/file/2023/8/57698_0s.jpg)
C#集合查询Linq在项目中使用详解
2022-09-16 13:50:09
Android编程之View简单学习示例
2022-10-28 16:51:43
![](https://img.aspxhome.com/file/2023/5/118975_0s.png)
+= 和 ++ 操作符区别简单介绍
2023-06-29 12:18:44
Android系统永不锁屏永不休眠的方法
2023-03-11 00:06:21
C# memcache 使用介绍
2022-11-25 12:25:57
![](https://img.aspxhome.com/file/2023/5/81135_0s.png)
Android实现读写USB串口数据
2023-10-21 19:12:56
![](https://img.aspxhome.com/file/2023/9/137749_0s.jpg)
Java下载远程服务器文件到本地(基于http协议和ssh2协议)
2022-08-29 12:23:18
![](https://img.aspxhome.com/file/2023/2/97952_0s.png)
Android中判断屏幕是否亮屏和是否解锁功能
2023-11-16 13:14:43
如何用Java Stream写出既高雅又装*的代码
2022-04-13 23:23:58
![](https://img.aspxhome.com/file/2023/6/65736_0s.jpg)