-2

I am making android app on Firebase and I want to see new data in top same as Facebook etc.

How to do to show data in my app in top when user upload new data please tell me how to do this

//layout recycler
recyler_view=(RecyclerView)findViewById(R.id.recyclerView);
recyler_view.setHasFixedSize(true);
layoutManager=new LinearLayoutManager(this);
recyler_view.setLayoutManager(layoutManager);

#xml#


    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </android.support.v7.widget.RecyclerView>

</LinearLayout>
mohd irfan
  • 57
  • 9

1 Answers1

0

Try applying this properties to your layoutManager

layoutManager.setStackFromEnd(true); // it will reverse the stack (bottom to top)
layoutManager.setReverseLayout(true); // When set to true, If RecyclerView is LTR, than it will layout from RTL
recyler_view.setLayoutManager(layoutManager);
Deep Patel
  • 2,584
  • 2
  • 15
  • 28