android显示段落文本及多行文本显示处理

先看效果

android显示段落文本及多行文本显示处理_第1张图片
android显示段落文本及多行文本显示处理_第2张图片
由于是图片,所以显示不出来滚动条,截了两张图片

贴代码

下面展示一些 内联代码片

<TextView
   android:id="@+id/textView9"
   android:layout_width="match_parent"
   android:layout_height="671dp"
   android:scrollbars="vertical"	//这两行
   android:singleLine="false"	//this
   app:layout_constraintBottom_toBottomOf="parent"
   app:layout_constraintEnd_toEndOf="parent"
   app:layout_constraintStart_toStartOf="parent" />
 //然后再activity当中添加以下代码
textView = findViewById(R.id.textView9);
public final news = "html文件格式的字符串";
textView.setText(Html.fromHtml(news));//这是显示段落文本的,通过解析html
textView.setMovementMethod(ScrollingMovementMethod.getInstance());//段落文本的话要加这个

你可能感兴趣的:(android)