图片缩放
private Bitmap scaleBitmap(Bitmap bitmap) { int originHeight = bitmap.getHeight(); Log.d("originHeight", originHeight + ""); int originWidth = bitmap.getWidth(); float scaleWidth = ((float) width)/ originWidth; float scaleHeight = ((float) height)/ originHeight; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); return Bitmap.createBitmap(bitmap, 0, 0, originWidth, originHeight, matrix, false); }属性动画
public void changePic(Bitmap bitmap) { currentBitmap = nextBitmap; nextBitmap = scaleBitmap(bitmap); ValueAnimator animator = ObjectAnimator.ofFloat(0, height); animator.setDuration(1000); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { offsetY = (float) animation.getAnimatedValue(); postInvalidate(); } }); animator.start(); }新闻热点
疑难解答