我有一个带有几个视图的recyclerView,一个是动画视图,它有一个动画应用于它.一旦视图离开屏幕,动画就不再有效,即使动画仍然存在.
数据:
rotate_around_center_point.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false" >
<rotate
android:duration="2500"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360" />
</set>
Run Code Online (Sandbox Code Playgroud)
应用动画:
animation = AnimationUtils.loadAnimation(this.getContext(),
R.anim.rotate_around_center_point);
loadingRotatingCircleIV.startAnimation(animation);
Run Code Online (Sandbox Code Playgroud)
当动画中断时我找不到任何捕捉事件的方法,所以我可以在动画离开屏幕后重新开始动画.
我在使用Alpha将PNG转换为JPEG时遇到了一些麻烦.
这是图像:http://upload.wikimedia.org/wikipedia/commons/thumb/e/ee/Radio_SRF_3.svg/500px-Radio_SRF_3.svg.png
原版的:

转换后的JPEG文件颜色错误.它现在更灰暗而不是更暗.

这就是我进行转换的方式:
删除alpha:
public static BufferedImage imageFillAlphaWithColor(BufferedImage image, Color fillColor) {
if (image.getColorModel().getTransparency() == Transparency.OPAQUE) return image;
int w = image.getWidth();
int h = image.getHeight();
BufferedImage newImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g = newImage.createGraphics();
g.drawImage(image, 0, 0, fillColor, null);
g.dispose();
return newImage;
}
Run Code Online (Sandbox Code Playgroud)
Jpeg压缩:
public static byte[] compressedJpegImage(BufferedImage image, float quality) {
byte jpegImage[] = null;
try {
// Find a jpeg writer
ImageWriter writer = null;
Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName("jpg");
if …Run Code Online (Sandbox Code Playgroud)