【开源】android-parallax-recyclerview
android-parallax-recyclerview
- https://github.com/kanytu/android-parallax-recyclerview
介绍:
recyclerview实现的List头部parallax(视差)效果。运行效果:
![]()
使用说明:
创建list对象并传递给ParallaxRecyclerAdapter
|
1
2
|
List<String> myContent = new ArrayList<String>(); // or another object listParallaxRecyclerAdapter myAdapter = new ParallaxRecyclerAdapter(myContent); // pass the list to the constructor |
实现ParallaxRecyclerAdapter.RecyclerAdapterMethods
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
myAdapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() { @Override public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) { // If you're using your custom handler (as you should of course) // you need to cast viewHolder to it. ((MyCustomViewHolder) viewHolder).textView.setText(myContent.get(i)); // your bind holder routine. } @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { // Here is where you inflate your row and pass it to the constructor of your ViewHolder return new MyCustomViewHolder(LayoutInflater.from( viewGroup.getContext()).inflate(R.layout.myRow, viewGroup, false)); } @Override public int getItemCount() { // return the content of your array return myContent.size(); }}); |
现在设置parallax header,同时需要将RecyclerView也传递进去,以监听其scroll事件
|
1
2
|
myAdapter.setParallaxHeader(LayoutInflater.from(this).inflate( R.layout.myParallaxView, myRecycler, false), myRecyclerView); |
posted on 2015-04-09 09:28 wasdchenhao 阅读(481) 评论(0) 收藏 举报

浙公网安备 33010602011771号