I make the chat display by dynamically adding message elements to the linearlayout. I ran into a problem. It is logical that when entering, lifting the keyboard scroll should not fall below and the keyboard should not close the message. To do this, I used the linearlayout property gravity = bottom, but now scrolling doesn't work. Please tell us how to make the scroll work not from the top down, but from the bottom up
<ScrollView
android:id="@+id/messscroll"
android:layout_width="match_parent"
android:layout_height="0dp"
android:direction="bottom_to_top"
android:gravity="bottom|center_horizontal"
app:layout_constraintBottom_toTopOf="@+id/relativeLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2">
<LinearLayout
android:id="@+id/messagebox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:baselineAligned="false"
android:adjustViewBounds="false"
android:clickable="true"
android:divider="@drawable/separator"
android:dividerPadding="3dp"
android:focusable="false"
android:focusableInTouchMode="false"
android:orientation="vertical"
android:paddingBottom="1px"
android:showDividers="middle">
</LinearLayout>
</ScrollView>
no need to scroll view for reverse scrolling layout use app:stackFromEnd="true" app:reverseLayout="true" properties of RecycleView to show chat bottom to top(new to old)