java Parallax RecyclerViewScrolling
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java Parallax RecyclerViewScrolling相关的知识,希望对你有一定的参考价值。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View parallaxAppBar = rootView.findViewById(R.id.parallax_appbar);
if (parallaxAppBar != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int max = parallaxAppBar.getHeight();
if (dy > 0) {
parallaxAppBar.setTranslationY(Math.max(-max, parallaxAppBar.getTranslationY() - dy / 2));
} else {
parallaxAppBar.setTranslationY(Math.min(0, parallaxAppBar.getTranslationY() - dy / 2));
}
}
});
}
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (recyclerView != null) {
recyclerView.clearOnScrollListeners();
}
}
以上是关于java Parallax RecyclerViewScrolling的主要内容,如果未能解决你的问题,请参考以下文章
Flutter 实现背景 Parallax 动画
parallax corrected cubemap
Parallax Mapping
html Pure Parallax CSS
html 纯CSS PARALLAX
html Parallax Pro定价表