react-native-navigation的迁移库

CollapsingViewPager.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.reactnativenavigation.views.collapsingToolbar;
  2. import android.content.Context;
  3. import android.support.v4.view.ViewPager;
  4. import android.view.View;
  5. public class CollapsingViewPager extends ViewPager implements CollapsingView {
  6. CollapsingViewMeasurer viewMeasurer;
  7. ViewCollapser viewCollapser;
  8. public CollapsingViewPager(Context context) {
  9. super(context);
  10. viewCollapser = new ViewCollapser(this);
  11. }
  12. public void setViewMeasurer(CollapsingViewMeasurer viewMeasurer) {
  13. this.viewMeasurer = viewMeasurer;
  14. }
  15. @Override
  16. protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  17. super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  18. setMeasuredDimension(viewMeasurer.getMeasuredWidth(widthMeasureSpec),
  19. viewMeasurer.getMeasuredHeight(heightMeasureSpec));
  20. }
  21. @Override
  22. public float getFinalCollapseValue() {
  23. return viewMeasurer.getFinalCollapseValue();
  24. }
  25. @Override
  26. public float getCurrentCollapseValue() {
  27. return getTranslationY();
  28. }
  29. @Override
  30. public View asView() {
  31. return this;
  32. }
  33. @Override
  34. public void collapse(CollapseAmount amount) {
  35. viewCollapser.collapse(amount);
  36. }
  37. }