1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { mImgKeyboard.setImageResource(KeyboardUtils.isSoftShowing(ForumsPublishPostActivity.this) ? R.mipmap.jianpan_down_ico : R.mipmap.jianpan_ico); Rect rect = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(rect); int invisibleHeight = rect.bottom - ViewUtils.getSystemBarHeight(ForumsPublishPostActivity.this) - ViewUtils.dp2px(ForumsPublishPostActivity.this, 44) - ViewUtils.dp2px(ForumsPublishPostActivity.this, 44); View etDescView = mRecyclerview.getLayoutManager().findViewByPosition(mAdapter.etFocusPosition); if (etDescView != null) { int focusViewTop = etDescView.getTop(); int itemHeight = etDescView.getHeight(); int differ = focusViewTop + itemHeight - invisibleHeight; if (differ > 0) { mRecyclerview.scrollBy(0, differ); } } } });
|