0

i add basically some properties to recyclerview to set reverse such as this code:

   <android.support.v7.widget.RecyclerView
       android:id="@+id/messagesView"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       app:layoutManager="LinearLayoutManager"
       app:reverseLayout="true"
       app:stackFromEnd="true"/>

what i try to do? i'm trying to show last item in recyclerview without scroll to last position, in pasted code i have first item in start and i have to scroll to last position programmatically

how can i change this xml layout to have this ability?

DolDurma
  • 15,753
  • 51
  • 198
  • 377

3 Answers3

1

You haven't posted any Java code. So try this:

Set this LayoutManager to the RecyclerView.

recyclerView.setLayoutManager(new LinearLayoutManager(context, VERTICAL, true)); 
Bob
  • 13,447
  • 7
  • 35
  • 45
1

Did you try to set the attributes from code? According to this question, that seems to work.

mLayoutManager = new LinearLayoutManager(getActivity());
mLayoutManager.setReverseLayout(true);
mLayoutManager.setStackFromEnd(true);
Ridcully
  • 23,362
  • 7
  • 71
  • 86
  • i remove properties from xml code and i try to set that programical, but it doesn't change view and i have list normally – DolDurma Aug 05 '17 at 16:34
1

Its worked for me , Moves the focus on Last item of the RecyclerView.

 mRecyclerView.getLayoutManager().smoothScrollToPosition(mRecyclerView,null, finalCustomItems.size()-1);

or,

mPagerAdapter.highlightPosition(listView.getAdapter().getItemCount() - 1);
Abhishek Kumar
  • 1,255
  • 13
  • 21