Android Animation when Scroll with images -


i having problem in creating animation have on box app in android. tried unable rotate image on next view.

so if people can provide guide..... appreciated.

this code class use swipe images

public class customhorizontalscrollview extends horizontalscrollview implements ontouchlistener, ongesturelistener, android.view.gesturedetector.ongesturelistener {

private static final int swipe_min_distance = 300;  private static final int swipe_threshold_velocity = 300;  private static final int swipe_page_on_factor=50;  private gesturedetector gesturedetector; private int scrollto = 0; private int maxitem = 0; private int activeitem = 0; private float prevscrollx = 0; private boolean start = true; private int itemwidth = 0; private float currentscrollx; private boolean flingdisable = true;  public customhorizontalscrollview(context context) {     super(context);     setlayoutparams(new layoutparams(layoutparams.fill_parent,             layoutparams.fill_parent)); }  public customhorizontalscrollview(context context, int maxitem,         int itemwidth) {     this(context);     this.maxitem = maxitem;     this.itemwidth = itemwidth;     gesturedetector = new gesturedetector(this);     this.setontouchlistener(this); }  @override public boolean ontouch(view v, motionevent event) {     if (gesturedetector.ontouchevent(event)) {         return true;     }     boolean returnvalue = gesturedetector.ontouchevent(event);      int x = (int) event.getrawx();      switch (event.getaction()) {     case motionevent.action_move:         if (start) {             this.prevscrollx = x;             start = false;         }         break;     case motionevent.action_up:         start = true;         this.currentscrollx = x;         int minfactor = itemwidth/ swipe_page_on_factor;          if ((this.prevscrollx - this.currentscrollx) > minfactor) {             if (activeitem < maxitem - 1)                 activeitem = activeitem + 1;          } else if ((this.currentscrollx - this.prevscrollx) > minfactor) {             if (activeitem > 0)                 activeitem = activeitem - 1;         }         system.out.println("horizontal : " + activeitem);         scrollto = activeitem * itemwidth;         this.smoothscrollto(scrollto, 0);         returnvalue = true;         break;     }     return returnvalue; }  public boolean onfling(motionevent e1, motionevent e2, float velocityx,         float velocityy) {     if (flingdisable)         return false;     boolean returnvalue = false;     float ptx1 = 0, ptx2 = 0;     if (e1 == null || e2 == null)         return false;     ptx1 = e1.getx();     ptx2 = e2.getx();     // right left      if (ptx1 - ptx2 > swipe_min_distance             && math.abs(velocityx) > swipe_threshold_velocity) {         if (activeitem < maxitem - 1)             activeitem = activeitem + 1;          returnvalue = true;      } else if (ptx2 - ptx1 > swipe_min_distance             && math.abs(velocityx) > swipe_threshold_velocity) {         if (activeitem > 0)             activeitem = activeitem - 1;          returnvalue = true;     }     scrollto = activeitem * itemwidth;     this.smoothscrollto(0, scrollto);     return returnvalue; }  public boolean ondown(motionevent e) {     return false; }  public void onlongpress(motionevent e) { }  public boolean onscroll(motionevent e1, motionevent e2, float distancex,         float distancey) {      return math.abs(distancey) > math.abs(distancex); }  public void onshowpress(motionevent e) { }  public boolean onsingletapup(motionevent e) {     return false; }  @override public void ongesturestarted(gestureoverlayview overlay, motionevent event) {     // todo auto-generated method stub  }  @override public void ongesture(gestureoverlayview overlay, motionevent event) {     // todo auto-generated method stub  }  @override public void ongestureended(gestureoverlayview overlay, motionevent event) {     // todo auto-generated method stub  }  @override public void ongesturecancelled(gestureoverlayview overlay, motionevent event) {     // todo auto-generated method stub  } 

}

main activity

public class mainactivity extends activity {

 private linearlayout linearlayout;  private customhorizontalscrollview horizontalscrollview;   int imgid[] = {  r.drawable.logo2, r.drawable.logo3,             r.drawable.logo4,};   protected void oncreate(bundle savedinstancestate) {   super.oncreate(savedinstancestate);   int width = mainactivity.this.getwindowmanager().getdefaultdisplay().getwidth();  int height = mainactivity.this.getwindowmanager().getdefaultdisplay().getheight();   horizontalscrollview = new customhorizontalscrollview(this, 3, width);   setcontentview(r.layout.activity_main);   linearlayout = (linearlayout) findviewbyid(r.id.layer);   linearlayout.addview(horizontalscrollview);    linearlayout container = new linearlayout(this);   container.setlayoutparams(new layoutparams(width, height));   // container.setheight(height);    textview textview = new textview(this);   textview.setwidth(width);  // textview.setheight(height);   textview.setgravity(gravity.center);    textview.setbackgroundresource(r.drawable.logo2);   container.addview(textview);    textview = new textview(this);   textview.setwidth(width);   textview.setheight(height);   textview.setgravity(gravity.center);    textview.setbackgroundresource(r.drawable.logo3);   container.addview(textview);    textview = new textview(this);   textview.setwidth(width);   textview.setheight(height);   textview.setgravity(gravity.center);     textview.setbackgroundresource(r.drawable.logo4);   container.addview(textview);    // imageview imageview=new imageview(this);     //imageview.setimageresource(r.drawable.logo3);     //imageview.setimageresource(r.drawable.logo4);     //imageview.setadjustviewbounds(true); //  imageview.setscaletype(scaletype.fit_xy); //  container.addview(imageview);      horizontalscrollview.addview(container);   }  } 

=========================== above snippet can swipe images want rotate image 90 degree vertical horizontal , wants shift same image next view proper axis....this want... new android. in advance.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -