-
縮放控制查看全部
-
activity.oncreate獲取控件寬高 OnGlobalLayoutListener onAttachedToWindow onDetachedFromWindow 多點(diǎn)觸控縮放 ScaleGestureDetector OnTouchListener OnScale detector 縮放修正 Matrix查看全部
-
多點(diǎn)觸控的中心點(diǎn)往往是實(shí)際使用的聚焦點(diǎn)查看全部
-
http://idcbgp.cn/video/6715查看全部
-
手勢(shì)操作查看全部
-
這個(gè)。。。。。。。。。。只能跟著敲敲了,不太明白查看全部
-
w*1.0f 直接轉(zhuǎn)換成小數(shù)查看全部
-
縮放動(dòng)畫改良了一下,做成時(shí)間常數(shù)式的,基本思路就是在固定的時(shí)間里確定次數(shù),并計(jì)算每次縮放的增量值,在最后一次里修正誤差。而老師的那個(gè)實(shí)現(xiàn),需要的時(shí)間和縮放比例是成正比的。 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()方法中的代碼,也可以在構(gòu)造方法中post(new Runnable() { @Override public void run() { // TODO 自動(dòng)生成的方法存根 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; // 圖片移動(dòng)至屏幕中心 mScaleMatrix.postTranslate((width - dw) / 2, (height - dh) / 2); mScaleMatrix.postScale(initScale, initScale, getWidth() / 2, getHeight() / 2); setImageMatrix(mScaleMatrix); } });這樣還可以省掉mOnce成員查看全部
-
https://github.com/bingoogolapple/AndroidCustomViewPlayground查看全部
-
圖片自由放大縮小、移動(dòng)等總結(jié)查看全部
-
當(dāng)前縮放值<最大縮放值,并且scaleFator>1.0-->還可以放大 當(dāng)前縮放值>最大縮放值,并且scaleFator<1.0-->還可以縮小查看全部
-
獲取當(dāng)前圖片的縮放值查看全部
-
Matrix數(shù)組查看全部
-
1231查看全部
舉報(bào)
0/150
提交
取消