3D parallax guide page

3D parallax guide page

Source code introduction: 3D parallax guide page, sub-control translation, zooming, 3D flipping when ViewPager slides

Source code effect:

Source code snippet:

  1. /**
  2. * When our ViewPager slides, each page will call back this method
  3. * position: the current page
  4. * view: the view corresponding to a page --- the layout view
  5. */  
  6. @Override  
  7. public   void transformPage(View view, float position) {
  8. // Gradient effect, judgment interval (-1, 1)  
  9. if (position< 1 && position >- 1 ) {
  10. // Parallax acceleration effect, giving all subspaces inside an acceleration offset  
  11. ViewGroup rl=(ViewGroup) view.findViewById(R.id.rl);
  12. // for (int i = 0; i < rl.getChildCount(); i++) {  
  13. // View child=rl.getChildAt(i);  
  14. // float factoe=(float) (Math.random()*2);  
  15. // if (child.getTag() == null) {  
  16. // child.setTag(factoe);  
  17. // }else{  
  18. // factoe=(Float) child.getTag();  
  19. // }  
  20. // // Acceleration offset (add an offset value to the child's original position)  
  21. // child.setTranslationX(-position*200*factoe);  
  22. // child.setTranslationY(position*100*factoe);  
  23. // }  
  24. // Zoom effect  
  25. // Scaling range: 0-1  
  26. rl.setScaleX(Math.max( 0 .8f, 1 -Math.abs(position)));
  27. rl.setScaleY(Math.max( 0 .8f, 1 -Math.abs(position)));
  28.               
  29. // 3D flip animation flips outward  
  30. // rl.setPivotX(position<0f?rl.getWidth():0f);  
  31. // rl.setPivotY(rl.getHeight()*0.5f);  
  32. // rl.setRotationY(position*90);  
  33.               
  34. // 3D flip animation flips inward  
  35. // rl.setPivotX(position<0f?rl.getWidth():0f);  
  36. // rl.setPivotY(rl.getHeight()*0.5f);  
  37. // rl.setRotationY(-position*90);  
  38.               
  39. // Mutton kebab effect  
  40. rl.setPivotX(rl.getHeight()* 0.5f );
  41. rl.setPivotY(rl.getHeight()* 0.5f );
  42. rl.setRotationY(-position* 90 );
  43. }
  44. }

Download address: http://download..com/data/2091673

<<:  The development of China's mobile game industry has grown sixfold in four years. What problems still exist?

>>:  QQ space stretchable head

Recommend

Functional Animation in UX Design

[[149375]] A good UX designer can easily explain ...

Xigua Video Product Analysis Report

Watching videos in free time has become an entert...

Individual exoskeleton! Let the "future soldier" have steel bones?

Exoskeleton, in its original definition, is simpl...

WebViewJavascriptBridge-Bridge between Obj-C and JavaScript

[[138163]] WebViewJavascriptBridge is an iOS/OSX ...

Su Shengjun's money-making system 20-lecture course video

Money Making System Course Catalog Earning money ...

Why are Chinese characters called “square characters”?

In the history of Chinese characters, people usua...