android - 键盘遮挡RecyclerView
大家讲道理
大家讲道理 2017-04-17 18:00:17
0
4
896

问题描述:
我使用 RecyclerView 来做消息列表,但是在软键盘弹起时会遮挡住 RecyclerView,而不是将 RecyclerView 与输入框一起顶上去。
清单文件里的 android:windowSoftInputMode 我设置为 adjustResize没效果。试过设置为 adjustPan,但是会将 标题栏也顶出布局外面。

问:该怎样才能做到像微信那样弹出软键盘会将 RecyclerView 顶上去?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(4)
黄舟

The title bar is pushed up probably because your layout file is not written correctly. I need to know how your xml is written. In addition, it is possible that it is not blocked and the RecyclerView does not slide to the bottom.

小葫芦

For RecyclerView, you need two configurations, one is, android:windowSoftInputMode="adjustResize", and the other is to add this when the code initializes RecyclerView

LinearLayoutManager layoutManager = new LinearLayoutManager(this);
//这是重点
layoutManager.setReverseLayout(true);
mRecyclerView.setLayoutManager(layoutManager);
大家讲道理

The code is incomplete, please complete it

小葫芦

AndroidManifest sets the soft keyboard state of Activity android:windowSoftInputMode="stateHidden|adjustResize"

//Set the layout manager
LinearLayoutManager mManager = new LinearLayoutManager(mContext);
mManager.setStackFromEnd(true); //Key
recyclerView.setLayoutManager(mManager);

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template