Java中的图像衰落

Java中的图像衰落,java,android,methods,Java,Android,Methods,我在Android Studio中尝试进行交叉衰落时遇到了一个问题。首先,我有以下代码在两个图像之间进行交叉淡入。代码运行良好 public class MainActivity extends AppCompatActivity { public void fade(View view) { ImageView front = (ImageView) findViewById(R.id.front); ImageView ima

我在Android Studio中尝试进行交叉衰落时遇到了一个问题。首先,我有以下代码在两个图像之间进行交叉淡入。代码运行良好

public class MainActivity extends AppCompatActivity {

        public void fade(View view) {
            ImageView front = (ImageView) findViewById(R.id.front);
            ImageView image1 = (ImageView) findViewById(R.id.image1);
            front.animate().alpha(0f).setDuration(1000);
            image1.animate().alpha(1f).setDuration(1000);
            image1.bringToFront();


        }

        public void fade1(View view) {
            ImageView front = (ImageView) findViewById(R.id.front);
            ImageView image1 = (ImageView) findViewById(R.id.image1);
            image1.animate().alpha(0f).setDuration(2000);
            front.animate().alpha(1f).setDuration(2000);
            front.bringToFront();

        }
但是,当我尝试使用三幅图像进行相同的淡入淡出时,代码不起作用。它不能正确地使图像褪色。以下是代码:

public void fade(View view) {
        ImageView front = (ImageView) findViewById(R.id.front);
        ImageView image1 = (ImageView) findViewById(R.id.image1);
        front.animate().alpha(0f).setDuration(1000);
        image1.animate().alpha(1f).setDuration(1000);
        image1.bringToFront();
    }

    public void fade1(View view) {
        ImageView image1 = (ImageView) findViewById(R.id.image1);
        ImageView image2= (ImageView) findViewById(R.id.image2);
        image1.animate().alpha(0f).setDuration(1000);
        image2.animate().alpha(1f).setDuration(1000);
        image2.bringToFront();

    }

    public void fade2(View view) {
        ImageView front = (ImageView) findViewById(R.id.image1);
        ImageView image2= (ImageView) findViewById(R.id.image2);
        image2.animate().alpha(0f).setDuration(1000);
        front.animate().alpha(1f).setDuration(1000);
        front.bringToFront();

    }

不知道出了什么问题。如有任何建议,将不胜感激。谢谢

R.id.image2
与上一个功能中的
front.animate..
不匹配(它们是转置动画?)。我想触摸顶视图,以便可以触摸它以执行淡入效果。不知道你的意思。你能澄清一下吗?
R.id.image2
与上一个功能中的
front.animate..
不匹配(它们是转置动画?)。我想触摸顶视图,以便可以触摸它以执行淡入效果。不知道你的意思。你能澄清一下吗?