android - Image Fading in Java -


i facing problem while trying cross fading in android studio. first, have following code cross fading between 2 images. code works fine.

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();          } 

but, when try same fading using 3 images, code doesn't work. doesn't fade images properly. here code:

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();      } 

not sure went wrong. suggestion appreciated. thank you


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -