跳至主要内容

博文

目前显示的是 六月, 2014的博文

How to make ViewPager auto play with a simple recursion function in android

Today a new request for ViewPager, will set ViewPager auto play, in last code is user Handler, but I want a new way to finish it. private void autoPlay (ViewPager viewPager ) {     viewPager . postDelayed ( new Runnable () {         @Override         public void run () {             try {                 if ( adapter != null && viewPager.getAdapter() . getCount () > 0 ) {                     int position = currentCount % adapter . getCount ();                     currentCount ++;                     viewPager . setCurrentItem ( position );                     autoPlay ( viewPager);             ...

How to change ViewPager scroll animation duration and velocity

When you call change current selected view pager position you may call like this. // change current position default is viewPager.setCurrentItem(position, true); viewPager . setCurrentItem ( position ); There will show transaction animation for change position , but this animation is too fast. So I want change this animation. When I see source code I find this, like flow. where is the scroll animation and speed.     int duration = 0 ;     velocity = Math . abs ( velocity );     if ( velocity > 0 ) {         duration = 4 * Math . round ( 1000 * Math . abs ( distance / velocity ));     } else {         final float pageWidth = width * mAdapter . getPageWidth ( mCurItem );         final float pageDelta = ( float ) Math . abs ( dx ) / ( pageWidth + mPageMargin );         duration = ( int ) (( pageDelta + 1 ) * 100 ); ...