android - Scrollview does not work on viewpager.pagetransformer -
i'm working viewpager fragments scrollview fade in- out animation.for purpose add function on viewpager.pagetransformer.when add feature scroll view not work properly(only first step data scroll ).
declaration on viewpager:
mviewpager = (viewpager) findviewbyid(r.id.pager); msectionspageradapter = new sectionspageradapter(getsupportfragmentmanager()); mviewpager.setpagetransformer(true, new crossfadepagetransformer()); mviewpager.setadapter(msectionspageradapter);
sectionspageradapter class are:
public class sectionspageradapter extends fragmentpageradapter { public sectionspageradapter(fragmentmanager fm) { super(fm); } @override public fragment getitem(int position) { // getitem called instantiate fragment given page. // return placeholderfragment (defined static inner class // below). return placeholderfragment.newinstance(position + 1); } @override public int getcount() { // show 3 total pages. return 3; } }
and crossfadepagetransformer class fade in-out animation :
public class crossfadepagetransformer implements viewpager.pagetransformer { @targetapi(build.version_codes.ice_cream_sandwich) @suppresslint("newapi") @override public void transformpage(view view, float position) { //working..... view.setscrolly(0); view.settranslationx(view.getwidth() * -position); if (position <= -1.0f || position >= 1.0f) { view.setalpha(0.0f); } else if (position == 0.0f) { view.setalpha(1.0f); } else { // position between -1.0f & 0.0f or 0.0f & 1.0f view.setalpha(1.0f - math.abs(position)); } }
how can solve issues?please suggest me.thanks all.
the thing viewpager
implements ontouchevent
, same scrollview
, interfere each other.
i'm afraid there no easy way make work, don't use nested scroll views.
Comments
Post a Comment