安卓适配
来源:互联网 发布:淘宝网介绍ppt 编辑:程序博客网 时间:2024/06/14 07:22
1、表情包的适配:ImageSpan
(1)、ImageSpan是通过bitmap生成的,如果要调整图片的大小,你可以对bitmap进行预处理,比如scale之类的操作,生成你目标的bitmap再生成ImageSpan。
(2)、可以把图片设置到ImageView里,调整好ImageView里图片的大小,再把ImageView生成对应的bitmap,从而生成ImageSpan。
(3)、测试:设置bitmap的参数
// Bitmap的配置参数 BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inDensity = context.getResources().getDisplayMetrics().densityDpi; opts.inTargetDensity = context.getResources().getDisplayMetrics().densityDpi; Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId, opts); // BitmapFactory.decodeResource(context.getResources(), resId); // bitmap = Bitmap.createScaledBitmap(bitmap, 60, 60, true); // 通过图片资源id来得到bitmap,用一个ImageSpan来包装 ImageSpan imageSpan = new ImageSpan(bitmap); Drawable drawable = context.getResources().getDrawable(R.drawable.emoji_1); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
(4)、matrix的类:操作bitmap的缩放:
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resId); Matrix matrix = new Matrix(); matrix.setScale(0.5f, 0.5f);// 缩小为原来的一半 Bitmap bm = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); ImageSpan span = new ImageSpan(bm, ImageSpan.ALIGN_BASELINE);
0 0
- 安卓适配
- 安卓适配
- 安卓适配探索
- 2dx 安卓适配
- 关于安卓适配的注意事项
- 安卓适配碰到的一些问题
- 记一次安卓适配的解决
- 安卓适配所有屏幕UI的方法
- 安卓适配之终极方案,百分比适配
- 安卓适配之android-percent-support-lib-sample的用法
- 终于等到你!MobileTest免费公测,华为带你走出安卓适配大坑
- 安卓适配 全面屏的适配(小米MIX2 的适配)
- UNC路径不受支持问题
- LINUX安装软件
- NodeJS | Js 对象 module.exports -笔记(1)
- NGUI制作显示tooltip需要注意的地方
- sqlsever 浅析存储过程 存储过程基础知识
- 安卓适配
- 《TCP/IP详解 卷1:协议》 读书笔记 第十八章 TCP连接的建立与终止
- Forward Example
- 键、索引、约束及其区别
- SendMessage
- redhat安装vnc
- 关于模型勾边Shader的文章
- Unity3D模型制作规范
- Jenkins进阶系列之——02email-ext邮件通知模板