1.xml中TextView增加此属性
android:scrollbars="vertical"
2.代码中增加setMovementMethod方法
mTvInfo = findViewById(R.id.tv_event_show); mTvInfo.setMovementMethod(ScrollingMovementMethod.getInstance());
3.自动定位至底部
public void tvShowBottom(){ mTvInfo.setText(mStrInfo); int offset=mTvInfo.getLineCount()*mTvInfo.getLineHeight(); if (offset > mTvInfo.getHeight()) { mTvInfo.scrollTo(0, offset - mTvInfo.getHeight()); } }