After Android swipeable TextView sets a large text, how to scroll to the end to display.

mResultTextView.setText(strResultText);
//通过行数X行高计算文字段落高度
int offset = mResultTextView.getLineCount() *mResultTextView.getLineHeight();
//如果文字段落高度大于可显示高度,则滑动到末尾(+20是为了让末尾不贴边)
if(offset -mResultTextView.getHeight() >0)
    mResultTextView.scrollTo(0, offset -mResultTextView.getHeight() +20);

Corresponding XML file properties:

<TextView android:id="@+id/result_text"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="5dp"	    
    android:scrollbars="vertical"
    android:fadeScrollbars="false">
</TextView>


{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324133137&siteId=291194637