Configure RecyclerView to work as a chat

前端 未结 3 1032
广开言路
广开言路 2020-12-28 21:24

To enable chat-style scrolling in a List View, we can use the following properties:



        
相关标签:
3条回答
  • 2020-12-28 21:49

    add these statements;

    <android.support.v7.widget.RecyclerView
                        android:id="@+id/chat_list_view"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:drawSelectorOnTop="false"
                        android:listSelector="@android:color/transparent"
                        android:paddingLeft="4dp"
                        android:paddingRight="4dp"
                        android:scrollbarStyle="outsideOverlay"
                        android:transcriptMode="normal" />
    

    and add into layout manager

    layoutManager.setStackFromEnd(true);
    
    0 讨论(0)
  • 2020-12-28 22:07

    RecyclerView has a stackFromEnd attribute.

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

    Or you can do it through code

    mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setReverseLayout(true);
    mLayoutManager.setStackFromEnd(true);
    
    0 讨论(0)
  • 2020-12-28 22:12

    add this two line to xml

    app:stackFromEnd="true"
    app:reverseLayout="true"
    
    0 讨论(0)
提交回复
热议问题