티스토리 뷰
애니메이션 적용
viewpager.setPageTransformer( false , new ViewPager.PageTransformer() { @Override public void transformPage(View page, float position) { // do transformation here } });
------ --------------------------------------------------------------page Apply the transformation to this page
position Position of page relative to the current front-and-center position of the pager.
0 is front and center. 1 is one full page position to the right,
and -1 is one page position to the left.
|
Now you have a variable that goes from 0 to 1 (and the other way, respectively) if the user scrolls the ViewPager. What you do with it is up to your imagination; here are some basic examples. First, we’ll fade the pages in and out: @Override public void transformPage(View page, float position) { final float normalizedposition = Math.abs(Math.abs(position) - 1 ); page.setAlpha(normalizedposition); } These lines perform a scaling effect from and to 50%: @Override public void transformPage(View page, float position) { final float normalizedposition = Math.abs(Math.abs(position) - 1 ); page.setScaleX(normalizedposition / 2 + 0 .5f); page.setScaleY(normalizedposition / 2 + 0 .5f); } The last example rotates the pages around their Z axis by 30 degrees; you don’t need to normalize for this one. The effect is similar to the cover flow UI pattern: @Override public void transformPage(View page, float position) { page.setRotationY(position * - 30 ); } |
개발사이트에서 제공하는 ViewPager 애니메이션
URL : http://developer.android.com/training/animation/screen-slide.html
'Language > Android' 카테고리의 다른 글
[Android] 안드로이드 NDK설치하기 (2) | 2014.03.02 |
---|---|
[Android] 원하는 기간 내의 thumbnail이미지 구하기 (0) | 2013.09.10 |
[Android] 안드로이드 에뮬레이터에 가상의 SD카드 마운트시키기 (0) | 2013.09.06 |
[Android] SQLite (0) | 2013.09.06 |
[Android] 밀리초, 날짜형식의 스트링 변경하는법 (0) | 2013.08.15 |
댓글
최근에 올라온 글
최근에 달린 댓글
글 보관함
- Total
- Today
- Yesterday