Well, it's time for us to learn the basics of control, in fact, the Guide page is very simple, that is, five photos
The traditional Viewpager implementation of the Guide page and the ListView is the same reason, just to change the ListView item into a picture, the Baseadapter replaced Pageradapter, we first look at the traditional guide page
Since the use of Viewpager, then the XML file must have Viewpager, careful you, you may find the last page and a button appears, yes, the XML file must have a button
Beginning also said, Viewpager in fact and the ListView, need a adapter, then from adapter start. Google offers a adapter--pageradapter that is designed to fit Viewpager
Basic Viewpager adapter are so written, is to add a list of the Viewpager to the view and delete the list of the view, it can be said that each Viewpager template
We find the corresponding Viewpager, and then set the adapter, the code initviews, Initlistener, InitData is executed sequentially, this code is not difficult, it is easy to read
Careful you may also find that the boot page is not in the status bar, so we need to set its theme for the status bar transparent
Special Note: It is important to note that the size of the picture problem, if the picture HD is too large, there may be a memory overflow error.
The animated Guide page writing procedure is identical to the tradition, except to set an animation for Viewpager. Google provides Viewpager.setpagetransformer (Boolean reversedrawingorder, Pagetransformer transformer) method to set the transition effect of the boot page, Let's look at the toggle demo provided by Google
From the above effect, just add an animation between the boot page, and Google provides the pagetransformer can be the current location of the guide page operation, such as: Set the change of transparency, set the zoom changes, you can achieve the animation effect of switching
From the above code, you can know when the Viewpager sliding, Su Yue will trigger Transformpage this method, and will be the current position and view pass, here is our view of the operation
①position
- Position < 1 (ie-infinity to-1): Let the boot page disappear with a transparency of 0
- Position <=0 (i.e.-1 to 0): Let the boot page appear
- Position <=1 (i.e. 0 to 1): Let the Guide page animate according to position
- Remaining else (1 to infinity): Let the boot page disappear with a transparency of 0
② schematic position
Forgive me for drawing not good-looking, not vivid, if you do not understand the words can be printed on their own log information, the view and position are printed out to help understand
Using Pagetransformer is very simple, as long as the Viewpager settings can be
Google also gives us another animated effect to see
The implementation steps are actually the same as the above steps, specifically we look at Pagetransformer's writing
The principle here is not analyzed, and the above is the same, but the operation is different. In addition to the demo provided by Google, we can imitate Google's demo, write our own animation effect
Effect
Well, today the basic control is here, if you do not understand the words can be practiced, and then use paper and pen thinking, you will have a harvest. I also learn other people's blogs through blogs, and then write out the content of the study through my own way. We'll refuel together, and then the men
Android Base Control--viewpager implementing a guided page with animations