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

Google plans to launch new Plaso mobile payment service to challenge Apple

[[127870]] On February 12, according to foreign m...

How many books have you read?

© Book Riot Leviathan Press: In 2006, a study on ...

Chen Chao: 60 Inventions That Influenced the World

Chen Chao · "60 Great Inventions That Influe...

How does Kuaishou achieve commercialization?

Video applications will be our focus for some tim...

Cool appearance suspected to be ZTE V5 new flagship product exposed

The new ZTE V5 has been exposed for some time. Pr...

What are the "black and white holes" on the road? You can't just hide from them!

Tunnel entrance and exit sections Why do accident...

How to carry out refined operation and promotion?

Precise operational promotion has become a rigid ...

Android GO system is developing slowly: only a dozen apps are available

At the Google I/O conference in 2017, Google anno...

iOS 13 screenshots leaked, dark mode confirmed

There is less than a week left before WWDC, and A...

His appearance from more than 1,400 years ago has been restored!

Wearing an imperial crown, lean and heroic, majes...