/**
* 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);
}
}
ParallaxRecyclerAdapter.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:Bailan
作者:
评论列表
文章目录