How can i make a dynamic flipping screen(like that of iPhone) in Android

后端 未结 4 1155
不知归路
不知归路 2020-12-23 12:52

I am parsing data through the web service. I want the flipping horizontally rather than vertically. Here is a tutorial where ViewFlipper is used but it is for static data.

4条回答
  •  爱一瞬间的悲伤
    2020-12-23 13:41

    You can add pages to a ViewFlipper dynamically using addView.

      flipper= (ViewFlipper) findViewById(R.id.flipper1);
      flipper.addView(myView,myViewIndex);
    

    Where myView is the view you wish to add, and myViewIndex is the index in the viewflipper you want to add this new view.

    You can then set the animations to preform on changing of views:

      flipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.left_in));
      flipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.left_out));
    

    Then to flip to this page you can use:

      flipper.setDisplayedChild(myViewIndex);
    

    Where left_in.xml is defined as

    
    
        
    
    

    and left_out.xml is:

    
    
        
    
    

提交回复
热议问题