mRecyclerview.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (bottom < oldBottom) {
mRecyclerview.post(new Runnable() {
@Override
public void run() {
if (mAdapter.getItemCount() > 0) {
mRecyclerview.smoothScrollToPosition(mAdapter.getItemCount() - 1);
}
//将RecyclerView定位到最后一行
}
});
}
}
});
//进入界面时加载mRecyclerview时mRecyclerview.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { ..