FeaturedRecyclerView

FeaturedRecyclerView is a custom ViewGroup which is made by extending ReyclerView. As name suggest FeaturedRecyclerView, it features the first item which is at top (by setting its height to featuredItemHeight).

Attributes

  • featuredItemHeight: Height of first item.
  • defaultItemHeight : Height of other items.
  • offset : It is not a xml attribute but a parameter which is received in FeaturedRecyclerViewAdapter's method to animate the property of childs widget.

sample_GIF

Diagramatic View

diagram_small

Concept

concept

FutureWork

  • Horizontal Orientation support would be added.
  • Reference Points would be changed.

Basic Usage

Add below lines in build.gradle at app level.

compile 'com.github.developer-shivam:FeaturedRecyclerView:1.0.0'

For a working implementation, see /app folder

FeaturedRecyclerView featuredRecyclerView = (FeaturedRecyclerView) findViewById(R.id.featured_recycler_view);
FeatureLinearLayoutManager layoutManager = new FeatureLinearLayoutManager(this);
featuredRecyclerView.setLayoutManager(layoutManager);
CustomRecyclerViewAdapter adapter = new CustomRecyclerViewAdapter(this, dummyData);featuredRecyclerView.setAdapter(adapter);

You must use FeaturedLinearLayoutManager to avoid flickering.

<developer.shivam.featuredrecyclerview.FeaturedRecyclerView android:id="@+id/featured_recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:featuredItemHeight="400dp"
    android:defaultItemHeight="200dp" />

Adavantages of using FeaturedRecyclerViewAdapter is that it contains two more methods which can be used to animate the properties of childs attribute (like textView fading).

    @Override
    public void onSmallItemResize(CustomRecyclerViewHolder holder, int position, float offset) {
       holder.tvHeading.setAlpha(offset / 100f);
    }

    @Override
    public void onBigItemResize(CustomRecyclerViewHolder holder, int position, float offset) {
       holder.tvHeading.setAlpha(offset / 100f);
    }

GitHub