聊天界面软键盘弹出,布局,消息移动到底部问题

inputText.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        smart_refresh.getLayout().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
            @Override
            public void onGlobalLayout() {
                recyclerView.scrollToPosition(adapter.getData().size() - 1);
                smart_refresh.getLayout().getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
        });
        return false;
    }
});

你可能感兴趣的:(android,小见)