コード例 #1
0
 public void setOnParallaxScroll(OnParallaxScroll parallaxScroll) {
   mParallaxScroll = parallaxScroll;
   mParallaxScroll.onParallaxScroll(0, 0, mHeader);
 }
コード例 #2
-1
 /**
  * Translates the adapter in Y
  *
  * @param of offset in px
  */
 public void translateHeader(float of) {
   float ofCalculated = of * mScrollMultiplier;
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB && of < mHeader.getHeight()) {
     mHeader.setTranslationY(ofCalculated);
   } else if (of < mHeader.getHeight()) {
     TranslateAnimation anim = new TranslateAnimation(0, 0, ofCalculated, ofCalculated);
     anim.setFillAfter(true);
     anim.setDuration(0);
     mHeader.startAnimation(anim);
   }
   mHeader.setClipY(Math.round(ofCalculated));
   if (mParallaxScroll != null) {
     final RecyclerView.ViewHolder holder = mRecyclerView.findViewHolderForAdapterPosition(0);
     float left;
     if (holder != null) {
       left = Math.min(1, ((ofCalculated) / (mHeader.getHeight() * mScrollMultiplier)));
     } else {
       left = 1;
     }
     mParallaxScroll.onParallaxScroll(left, of, mHeader);
   }
 }