图像变化,多点触控
来源:互联网 发布:mac ae渲染快捷键 编辑:程序博客网 时间:2024/06/18 09:21
图像绘制
//绘制图像(位图对象,位图左上角x坐标,位图左上角y坐标)canvas.drawBitmap(mBitmap, 50, 10, null);//第二个参数表示图像上的区域,可以null,null表示全图//第三个参数表示画布上显示图像的区域canvas.drawBitmap(gameBitmap, bitmapRect, showRect, null);
图像变换
需要有Matrix对象来处理
Matrix mMatrix = new Matrix(); //角度0 缩放倍数1 偏移0
set:
设置一个新状态mMatrix.setTranslate(100,200);
post:
基于上一个状态累加新状态mMatrix.postRotate(90);
pre:
前置状态,如需要对图片进行平移(100,200)放大2倍mMatrix.postTranslate(100,200);mMatrix.postScare(2,2);mMatrix.postScare(2,2);mMatrix.preTranslate(100,200);
//基于矩阵绘制图像
canvas.drawBitmap(mBitmap,mMatrix,null);
多点触控
int action = event.getAction(); switch (action & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: //单个触控按下 break; case MotionEvent.ACTION_POINTER_DOWN: //多个触控点按下 break; case MotionEvent.ACTION_MOVE: 按下之后离开之前都会触发 break; case MotionEvent.ACTION_UP: 单个触控离开 break; case MotionEvent.ACTION_POINTER_UP: 多个触控离开 break; }
获取精确的触控点个数
int count = event.getPointerCount(); //获取总个数for(int i = 0 ; i < count ; i++){ int x = event.getX(i); int y = event.getY(i);}
自定义ViewGroup
onMeasure先measure孩子再measure自身
measureChildren(widthMeasureSpec,heightMeasureSpec);或者int count = getChildCount(); int totalHeight = MeasureSpec.getSize(heightMeasureSpec); for (int i = 0; i < count; i++) { View child = getChildAt(i); measureChild(child, widthMeasureSpec,heightMeasureSpec); }
measure自身
setMeasuredDimension(widthMeasureSpec, resolveSize(totalHeight, heightMeasureSpec));
onLayout布置孩子的显示
//对孩子进行布局的方法@Overrideprotected void onLayout(boolean changed, int l, int t, int r, int b) { int width = getMeasuredWidth() / 2; int count = getChildCount(); int currentHeight = 0; for (int i = 0; i < count; i++) { View child = getChildAt(i); int left = 0; if (i % 2 != 0) { left = width; } child.layout(left, currentHeight, left + width, currentHeight + child.getMeasuredHeight()); //累计高度 currentHeight += child.getMeasuredHeight(); }}
0 0
- 图像变化,多点触控
- 多点触控
- android多点触控
- Android多点触控
- 多点触控
- 触摸屏多点触控
- android 多点触控
- android 多点触控
- 多点触控参数
- 多点触控
- 多点触控
- android 多点触控
- android 多点触控
- 多点触控 - MFC
- Android多点触控
- 多点触控1
- windows 多点触控
- Android多点触控
- 1110. Complete Binary Tree (25)
- 如何快速比较两张表内同是否相同
- 数据结构与算法各种概念总结-持续更新中
- 预览图,用表单写
- SE38查到DEMO示例程序及ALV示例程序。
- 图像变化,多点触控
- 函数_内部&外部/全局&局部_函数/变量
- java学习心得(-)
- Github和OSChina设置SSH公钥免用户名、密码操作
- ffmpeg解复用流程
- eclipse启动卡死在org.eclipse.mylyn.tasks.ui
- 字符串中的快速模式匹配2
- 山东省第八届ACM大学生程序设计竞赛 训练总结 [8/11] 待补
- Together项目后台开发01