Android uses viewflipper to switch pictures
Today, let's briefly talk about Android gestures. At present, gestures are rarely used in apps on the market. Android provides two kinds of gestures: ①. Android provides gesture detection and provides corresponding listeners for gesture detection ②. Android allows developers to add gestures and provides corresponding APIs to recognize user gestures
In a previous blog, I talked about how to use viewpager to realize image sliding and address switching: Android uses viewpager to realize image sliding preview effect
However, viewpager has its own gesture recognition, which means that it will automatically recognize whether the gesture is sliding right or left. Today, I'll talk about how to use the viewflipper control to realize picture sliding switching. The code is very simple. I'll write the implementation code below.
activity_ mian.xml
Viewpager has its own animation for image switching, and viewflipper does not have its own animation for switching, so we can write the animation first, and now create a folder anim under the res folder
Then write the animation file in the anim folder
left_ in.xml
left_ out.xml
right_ in.xml
right_ out.xml
MainActivity.java
The above code can realize picture switching!
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.