【开源】android-parallax-recyclerview

android-parallax-recyclerview

 

使用说明:

创建list对象并传递给ParallaxRecyclerAdapter

1
2
List<String> myContent = new ArrayList<String>(); // or another object list
ParallaxRecyclerAdapter 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);

 

相关代码

  • ParallaxPagerTransformer
  • ParallaxListView
  • RecyclerViewFastScroller
  • UltimateRecyclerView
  • android-advancedrecyclerview

posted on 2015-04-09 09:28  wasdchenhao  阅读(481)  评论(0)    收藏  举报

导航