我正在使用PhotoView组件在Android中缩放和平移图像.但是,当它首先进入图像所在的页面时,它位于左上角,当我尝试平移或缩放时,它会转移到中间.有没有人有这个组件的经验,知道如何调整图像的初始位置,并防止它跳到屏幕中间?
我正在使用这个图书馆的photoview com.github.chrisbanes:PhotoView:1.3.1.但是我的Gradle没有同步.
我已经在这个网址上添加了Gradle Dependancy的Maven代码:https://github.com/chrisbanes/PhotoView
我正在使用https://github.com/chrisbanes/PhotoView并尝试设置其高度的动画.
我使用ValueAnimator并更新布局高度,以便触发内部PhotoViewAttacher并onGlobalLayout转换矩阵.
是否有任何解决方法可以防止比例和y位置不变,就像我自己更新矩阵以保持图像Y位置和scaleX/scaleY不变?现在重置为缩放1.0和y位置图像中心.
动画代码:
ValueAnimator animator = ValueAnimator.ofInt(start, end).setDuration(300);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
mImageView.getLayoutParams().height = (int) animation.getAnimatedValue();
mImageView.requestLayout();
}
});
animator.start();
Run Code Online (Sandbox Code Playgroud) 我确实使用 PhotoView 库来放大。现在,当用户单击按钮时,我准备旋转 PhotoView,高度和宽度将旋转。所以宽度小于屏幕高度。这导致我在旋转图像视图之前无法像往常一样获得全屏缩放。
因此,任何解决方案都可以使旋转后的新宽度或高度全屏显示。
示例:这是缩放图像,它不会像旋转之前那样放大整个屏幕
android image-rotation android-imageview android-orientation android-photoview