小编Arn*_*rny的帖子

当视图超出屏幕时,Android视图动画停止

我有一个带有几个视图的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)

当动画中断时我找不到任何捕捉事件的方法,所以我可以在动画离开屏幕后重新开始动画.

xml animation android view

9
推荐指数
2
解决办法
982
查看次数

如何使用JAVA将带有alpha的PNG转换为JPEG保存颜色

我在使用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)

java png jpeg alpha colors

7
推荐指数
1
解决办法
2451
查看次数

标签 统计

alpha ×1

android ×1

animation ×1

colors ×1

java ×1

jpeg ×1

png ×1

view ×1

xml ×1