Android realizes gesture sliding and simple animation effects

1、 Gesture sliding

1. All activities have the ability to respond to touch events, that is, as long as the activity is touched, it will call back an ontouchevent () method. However, events cannot be processed in this method. We need to use the method ontouchevent in the gesture detector to analyze and process events. We only need to rewrite the operations in this method to meet our needs.

2. We need to make interface jump according to sliding gestures. Gesturedetector encapsulates methods that can monitor different gestures. In which activity this method is used, the activity can listen to the actions received by the activity, and the required actions can be rewritten in these methods.

Note: page coordinates

2、 Simple animation

Purpose: write a transition animation of activity jump page with XML file.

1. Create an anim folder in the res directory, create two XML files and edit the animation action, one is the entry action and the other is the exit action.

(1) In anim_ next_ Write the entry action in in. XML.

(2) In anim_ next_ Write the exit action in out.xml.

2. Call the overridependingtransition method of activity to realize translation animation.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>