Skip to content

A RecyclerView's Adapter that allows to add a custom header view, scrolled with a parallax effect.

Notifications You must be signed in to change notification settings

arcadefire/parallax-recycler-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parallax Recycler Adapter

A simple RecyclerView adapter that enable the RecyclerView to add a top header, which is scrolled with a parallax effect.

The usage is pretty simple. Just get the instance of the RV inserted in your layout and attach to it the adapter, together with the header's layout resource Id, in the Adapter's constructor.

After this, you should override the abstract methods, that handle the creation of new items and the bind of a model instance to specific viewholder, like it happens in a default RV's adapter.

The method onBindNonHeaderViewHolder also returns the model's istance associated with the Adapter directly as a parameter.

RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));

ParallaxHeaderRecyclerAdapter headerRecyclerAdapter = new ParallaxHeaderRecyclerAdapter<CustomClass>(recyclerView, R.layout.layout_header) {
    @Override
    protected RecyclerView.ViewHolder onCreateNonHeaderViewHolder(ViewGroup viewGroup, int viewType) {
        return new HeaderViewHolder(LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.layout_item, viewGroup, false));
    }

    @Override
    protected void onBindNonHeaderViewHolder(RecyclerView.ViewHolder viewHolder, int position, CustomClass item) { 
      // do some layout stuff
      }
    };
        
  headerRecyclerAdapter.append(new CustomClass());
  recyclerView.setAdapter(headerRecyclerAdapter);

About

A RecyclerView's Adapter that allows to add a custom header view, scrolled with a parallax effect.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages