【问题标题】:Scale Animation not smooth in android on image view在图像视图上的 android 中缩放动画不平滑
【发布时间】:2016-07-13 06:47:31
【问题描述】:

我使用 Scale Animation 在我的应用中缩放图像。它可以正常缩放图像级别,这是我们想要的,但我的问题是缩放图像时不缩放 smooth。 图像大小为 1.4 mb。

ScaleAnimation scaleAnimation = new ScaleAnimation(1f, 2.5f,
                        1f, 2.5f, Animation.RELATIVE_TO_PARENT,
                        1.05f, Animation.RELATIVE_TO_PARENT, 1.05f);
  scaleAnimation.setFillAfter(true);
  scaleAnimation.setDuration(400);
  img.startAnimation(scaleAnimation);

【问题讨论】:

  • 查看我的方法并尝试一下。
  • 好的,我试试看.. 一段时间后@Ironman

标签: android animation android-animation android-imageview scaleanimation


【解决方案1】:

如果你的min sdk版本大于13那么你可以试试

img.animate().scaleX(2.5f).scaleY(2.5f).setDuration(400).start();

【讨论】:

    【解决方案2】:

    Zoom animation smoothlyHere. 的 Android 动画

    您可以自定义它们以使其更流畅。

    【讨论】:

      【解决方案3】:

      创建scale_up.xml

      <set xmlns:android="http://schemas.android.com/apk/res/android">
          <scale android:fromXScale="1"
                 android:fromYScale="1"
                 android:toXScale="1.2"
                 android:toYScale="1.2"
                 android:pivotX="50%"
                 android:pivotY="50%"
                 android:duration="400"/>
      </set>
      

      并以这种方式使用..

      Animation animation = AnimationUtils.loadAnimation(this, R.anim.scale_up);
      ((ImageView) findViewById(R.id.circle_image)).startAnimation(animation );
      

      它会给你流畅的动画。

      注意:确保要获得流畅的动画,您必须设置 android:pivotXandroid:pivoty 到屏幕的一半。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-11-15
        • 2010-11-25
        • 2015-01-11
        • 1970-01-01
        • 2012-12-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多