RotateAnimation 在具有 alpha 的 ImageView 后面时滞后
RotateAnimation lags when behind ImageView with alpha
我有下一个RotateAnimation
.
private RotateAnimation createImageRotatingAnimationInfinite(ImageView imageView) {
RotateAnimation animation = new RotateAnimation(0f, 360f, imageView.getWidth() / 2, imageView.getHeight() / 2);
animation.setFillAfter(true);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE);
animation.setDuration(ROTATE_DURATION);
return animation;
}
下一个布局:
...
<!--ROTATING BACKGROUND-->
<com.bipfun.nightlight.customviews.SquareHImageView
android:id="@+id/a_main_rotating_bckgnd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:src="@drawable/rotating_bckgnd_default"/>
<!--LIGHT BACKGROUND-->
<ImageView
android:id="@+id/a_main_light_bckgnd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:scaleType="centerCrop"
android:src="@drawable/bckgnd_stars_light"/>
...
我将动画设置为 a_main_rotating_bckgnd
,当我在屏幕上移动取景器 upwards/donwards 时,我修改了 a_main_light_bckgnd
的 alpha
值。问题是对于任何 alpha > 0
,其背后的旋转背景都会像疯了似的滞后。它只发生在一些设备上,比如 HTC One、三星 S3、三星 Note II。
APIs不同,分别是4.1.2、4.3和4.4.2。它不能像其他具有类似 API 的设备那样工作 API。他们都有 xhdpi
屏幕,但我已经用小图像作为背景尝试过,但他们仍然滞后。
我好像想不通。我需要一个图像在前面,因为它需要是位图。我还有一个简单的 View
,我将 背景颜色 设置为 #50000000
之类的东西(因此 alpha 为 50),但这似乎不是影响旋转动画。
有什么解决这个问题的想法吗?
问题是所有 3 台设备都在使用 xhdpi
可绘制对象。我错误地删除了 Fragment
的背景,我发现它不再滞后。所以我改变了一切。将图像从 hdpi
-> xhdpi
、xhdpi
-> xxhdpi
移动,之后一切正常。它似乎无法同时处理屏幕上太多的大图像。
我有下一个RotateAnimation
.
private RotateAnimation createImageRotatingAnimationInfinite(ImageView imageView) {
RotateAnimation animation = new RotateAnimation(0f, 360f, imageView.getWidth() / 2, imageView.getHeight() / 2);
animation.setFillAfter(true);
animation.setInterpolator(new LinearInterpolator());
animation.setRepeatCount(Animation.INFINITE);
animation.setDuration(ROTATE_DURATION);
return animation;
}
下一个布局:
...
<!--ROTATING BACKGROUND-->
<com.bipfun.nightlight.customviews.SquareHImageView
android:id="@+id/a_main_rotating_bckgnd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="centerCrop"
android:src="@drawable/rotating_bckgnd_default"/>
<!--LIGHT BACKGROUND-->
<ImageView
android:id="@+id/a_main_light_bckgnd"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:scaleType="centerCrop"
android:src="@drawable/bckgnd_stars_light"/>
...
我将动画设置为 a_main_rotating_bckgnd
,当我在屏幕上移动取景器 upwards/donwards 时,我修改了 a_main_light_bckgnd
的 alpha
值。问题是对于任何 alpha > 0
,其背后的旋转背景都会像疯了似的滞后。它只发生在一些设备上,比如 HTC One、三星 S3、三星 Note II。
APIs不同,分别是4.1.2、4.3和4.4.2。它不能像其他具有类似 API 的设备那样工作 API。他们都有 xhdpi
屏幕,但我已经用小图像作为背景尝试过,但他们仍然滞后。
我好像想不通。我需要一个图像在前面,因为它需要是位图。我还有一个简单的 View
,我将 背景颜色 设置为 #50000000
之类的东西(因此 alpha 为 50),但这似乎不是影响旋转动画。
有什么解决这个问题的想法吗?
问题是所有 3 台设备都在使用 xhdpi
可绘制对象。我错误地删除了 Fragment
的背景,我发现它不再滞后。所以我改变了一切。将图像从 hdpi
-> xhdpi
、xhdpi
-> xxhdpi
移动,之后一切正常。它似乎无法同时处理屏幕上太多的大图像。