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

There is a "microbial city" in our mouth

The invention of the microscope first expanded pe...

Where is the future of new media operations?

A few months ago, a friend who works in new media...

Android WeChat released version 7.0.22, adding many new features

Recently, Android WeChat released the official ve...

What is the idea behind operating and promoting a successful event?

Recently a friend asked me on WeChat: Why is it t...

Analysis of Douyin short video competitors!

Analysis of Douyin short video competitors 1. Bac...

How to operate a good community?

Introduction: Although all operations have common...

Does smoking affect your appearance? It’s true!

Author: Xiao Dan, Director of the Department of T...

Do you always feel that your cat is not right? Be careful...it may be mentally ill

Key Points ★ From a human psychology perspective,...

How to better cultivate users' ability and habits to pay?

Today we are going to talk about a common and rel...