Horizontal Recyclerview With Nice Animation Android
How to make such like horizontal recycle view with nice UI animation. Note: I can make horizontal recyclerview. but how can it start from middle and when scroll it comes in start?
Solution 1:
Set padding left on Recyclerview
as below code to start your recyclerView
row as per padding left :
your Xml code should be like this :
<LinearLayoutandroid:layout_marginTop="8dp"android:background="@drawable/banner2"android:layout_width="match_parent"android:layout_height="240dp"><android.support.v7.widget.RecyclerViewandroid:paddingLeft="180dp"android:layout_marginTop="17dp"android:id="@+id/recycler_kids"android:layout_width="match_parent"android:layout_height="match_parent"android:clipToPadding="false"app:layout_behavior="@string/appbar_scrolling_view_behavior" /></LinearLayout>
Look into this for detect hiding row on recyclerview to show background image Hiding views in RecyclerView
Solution 2:
To Start horizontal RecyclerView with a starting empty space Use:
recyclerView.addItemDecoration(new HorizontalSpaceItemDecoration(700));
and define Class: HorizontalSpaceItemDecoration(); as
publicclassHorizontalSpaceItemDecorationextendsRecyclerView.ItemDecoration {
privatefinalint mHorizontalSpaceWidth;
publicHorizontalSpaceItemDecoration(int mHorizontalSpaceWidth) {
this.mHorizontalSpaceWidth = mHorizontalSpaceWidth;
}
@OverridepublicvoidgetItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
if (parent.getChildAdapterPosition(view) == 0) {
outRect.left = mHorizontalSpaceWidth;
}
}
Solution 3:
my solution is to add blank item at first.
@OverridepublicintgetItemViewType(int position) {
if (position==0){
return1;
}else {
returnsuper.getItemViewType(position);
}
}
you need to create blank item in xml for that
Solution 4:
You can use this in your adapter :
if (position == 0) {
holder.card_zero.setVisibility(View.VISIBLE);
holder.card_info.setVisibility(View.GONE);
holder.card_pic.setVisibility(View.GONE);
} else {
holder.card_zero.setVisibility(View.GONE);
holder.card_info.setVisibility(View.VISIBLE);
holder.card_pic.setVisibility(View.VISIBLE);
Solution 5:
Linearlayout manager with horizontal orientation and PagerSnapHelper()
will be helpful to achieve this. Following code from pagersnap will provide better illustration.
RecyclerViewrecyclerView= (RecyclerView) view.findViewById(R.id.recycler_view);
LinearLayoutManagerlayoutManager=newLinearLayoutManager(context,
LinearLayoutManager.HORIZONTAL, false);
SnapHelpersnapHelper=newPagerSnapHelper();
recyclerView.setLayoutManager(layoutManager);
snapHelper.attachToRecyclerView(mRecyclerView);
Post a Comment for "Horizontal Recyclerview With Nice Animation Android"