-
缩放控制查看全部
-
activity.oncreate获取控件宽高 OnGlobalLayoutListener onAttachedToWindow onDetachedFromWindow 多点触控缩放 ScaleGestureDetector OnTouchListener OnScale detector 缩放修正 Matrix查看全部
-
多点触控的中心点往往是实际使用的聚焦点查看全部
-
http://www.imooc.com/video/6715查看全部
-
手势操作查看全部
-
这个。。。。。。。。。。只能跟着敲敲了,不太明白查看全部
-
w*1.0f 直接转换成小数查看全部
-
缩放动画改良了一下,做成时间常数式的,基本思路就是在固定的时间里确定次数,并计算每次缩放的增量值,在最后一次里修正误差。而老师的那个实现,需要的时间和缩放比例是成正比的。 private class ScaleAnimation implements Runnable { private float targetScale = 0.0f; private float x = 0.0f; private float y = 0.0f; private int time = 0; private int count = 0; private int step = 0; private float deltaScale = 0.0f; private final int TIME_UNIT = 16; ScaleAnimation(float targetScale, float x, float y, int time) { super(); this.targetScale = targetScale; this.x = x; this.y = y; this.time = time; count = time / TIME_UNIT + 1; deltaScale = (float) Math.pow(targetScale / getScale(), 1.0f / count); } @Override public void run() { step++; if (step == count) {// 最后一次修正累积误差 deltaScale = targetScale / getScale(); } scaleMatrix.postScale(deltaScale, deltaScale, x, y); checkBorderAndCenterWhenScale(); setImageMatrix(scaleMatrix); if (step < count) { postDelayed(this, TIME_UNIT); } else { scaleProcessing = false; } } }查看全部
-
onGlobalLayout()方法中的代码,也可以在构造方法中post(new Runnable() { @Override public void run() { // TODO 自动生成的方法存根 Drawable d = getDrawable(); if (d == null) { return; } int width = getWidth(); int height = getHeight(); // 拿到图片的宽和高 int dw = d.getIntrinsicWidth(); int dh = d.getIntrinsicHeight(); float scale = 1.0f; scale = Math.min(width * 1.0f / dw, height * 1.0f / dh); initScale = scale; // 图片移动至屏幕中心 mScaleMatrix.postTranslate((width - dw) / 2, (height - dh) / 2); mScaleMatrix.postScale(initScale, initScale, getWidth() / 2, getHeight() / 2); setImageMatrix(mScaleMatrix); } });这样还可以省掉mOnce成员查看全部
-
https://github.com/bingoogolapple/AndroidCustomViewPlayground查看全部
-
图片自由放大缩小、移动等总结查看全部
-
当前缩放值<最大缩放值,并且scaleFator>1.0-->还可以放大 当前缩放值>最大缩放值,并且scaleFator<1.0-->还可以缩小查看全部
-
获取当前图片的缩放值查看全部
-
Matrix数组查看全部
-
1231查看全部
举报
0/150
提交
取消