Skip to content

Commit 2031c6c

Browse files
b-fgsamtstern
authored andcommitted
Scroll to end when keyboard is shown. (#1270)
1 parent 1481e4d commit 2031c6c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

app/src/main/java/com/firebase/uidemo/database/firestore/FirestoreChatActivity.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7878
mRecyclerView.setHasFixedSize(true);
7979
mRecyclerView.setLayoutManager(manager);
8080

81+
mRecyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
82+
@Override
83+
public void onLayoutChange(View view, int left, int top, int right, int bottom,
84+
int oldLeft, int oldTop, int oldRight, int oldBottom) {
85+
if (bottom < oldBottom) {
86+
mRecyclerView.postDelayed(new Runnable() {
87+
@Override
88+
public void run() {
89+
mRecyclerView.smoothScrollToPosition(0);
90+
}
91+
}, 100);
92+
}
93+
}
94+
});
95+
8196
ImeHelper.setImeOnDoneListener(mMessageEdit, new ImeHelper.DonePressedListener() {
8297
@Override
8398
public void onDonePressed() {

0 commit comments

Comments
 (0)