ViewPager every page is Fragment,
For example, I slid from page 1 page 2
then play page 2 prefabricated animation, (imagine the button from page 2 above Move to bottom ),
Then I slid from page 1 page 2
(Imagine the button from page 2 bottom Move to above ),
then play the movie page 1
Then, If you drag your finger on the page 2 and page 1 of the middle part, the page 2 button also stopped in the middle of the displacement
This is my description of the specific implementation, ambiguous and seek my own guidance about
------ Solution -------------- ------------------------------
you can use to customize your ViewPager.PageTransformer switching animation.
The following code from the official website: http://developer.android.com/training/animation/screen-slide.html # pagetransformer
public class DepthPageTransformer implements ViewPager.PageTransformer {
private static float MIN_SCALE = 0.75f;
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
if (position < -1) { // [-Infinity,-1)
// This page is way off-screen to the left.
view.setAlpha(0);
} else if (position <= 0) { // [-1,0]
// Use the default slide transition when moving to the left page
view.setAlpha(1);
view.setTranslationX(0);
view.setScaleX(1);
view.setScaleY(1);
} else if (position <= 1) { // (0,1]
// Fade the page out.
view.setAlpha(1 - position);
// Counteract the default slide transition
view.setTranslationX(pageWidth * -position);
// Scale the page down (between MIN_SCALE and 1)
float scaleFactor = MIN_SCALE
+ (1 - MIN_SCALE) * (1 - Math.abs(position));
view.setScaleX(scaleFactor);
view.setScaleY(scaleFactor);
} else { // (1,+Infinity]
// This page is way off-screen to the right.
view.setAlpha(0);
}
}
}
------ For reference only ----------------------------------- ----
even a passerby did not appear ... Well
still rely on their own ah .. Fortunately, the completion of the study has been written out
------ For reference only --------------- ------------------------
Share next chant
------ For reference only ------------------------------- --------
Thank you for your answer! original can also toggle this adjustment ViewPager animation!
Here too, I just want to make ViewPager inside each Page in the widget animation,
and with the degree of stretching, the corresponding change in position of the animation!
I probably approach is:
1) Rewrite ViewPager control method in the callback interface in onPageScrolled return sliding direction, distance, and percentage.
2) and then by sliding percentage calculated degree of completion of the execution of the animation, play the corresponding animation, and then save a temporary animation point.
------ For reference only ---- -----------------------------------
Thank you for your answer! original can also toggle this adjustment ViewPager animation!
Here too, I just want to make ViewPager inside each Page in the widget animation,
and with the degree of stretching, the corresponding change in position of the animation!
I probably approach is:
1) Rewrite ViewPager control method in the callback interface in onPageScrolled return sliding direction, distance, and percentage.
2) and then by sliding percentage calculated degree of completion of the execution of the animation, play the corresponding animation, and then save a temporary animation point.
glance, hehe.
------ For reference only -------------------------------------- -
landlord, Results posted to the sub-ah.
------ For reference only ---------------------------------------
Thank you to share!
------ For reference only ---------------------------------------
here 0 , 1 refers to the distance between the sliding scale it
------ For reference only ---------------------------- -----------
here 0,1 refers sliding distance scaling it
It can be understood.
The position parameter indicates where a given page is located relative to the center of the screen. ; It is a dynamic property that changes as the user scrolls through the pages. When a page fills the screen, its position value ; is 0. When a page is drawn just off the right side of the screen, its position value is 1. If the ; user scrolls halfway between pages one and two, page one has a position of -0.5 and page two has a position of 0.5 . Based on the position of the pages on the screen, you can create custom slide animations by setting page properties with methods such ; as setAlpha (), setTranslationX (), or setScaleY ().
------ For reference only ----------------- ----------------------
mark a record, learning
------ For reference only ------- --------------------------------
here 0,1 refers sliding distance What proportion of
It can be understood.
The position parameter indicates where a given page is located relative to the center of the screen. ; It is a dynamic property that changes as the user scrolls through the pages. When a page fills the screen, its position value ; is 0. When a page is drawn just off the right side of the screen, its position value is 1. If the ; user scrolls halfway between pages one and two, page one has a position of -0.5 and page two has a position of 0.5 . Based on the position of the pages on the screen, you can create custom slide animations by setting page properties with methods such ; as setAlpha (), setTranslationX (), or setScaleY ().
ah very clear so easy to animate
没有评论:
发表评论