如何水平和垂直滚动TextView的内容 [英] how to make scrollable horizontally and vertically the contents of a TextView

查看:78
本文介绍了如何水平和垂直滚动TextView的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想滚动在TextView中查看的结果,这是我的xml:

I want to scroll the results that view in a TextView, this my xml:

<scroll>
<TextView
android:id="@+id/ris"
android:layout_width="wrap_content"
android:layout_height="229dp"
android:layout_weight="0.96"
android:textAppearance="?android:attr/textAppearanceMedium" />
</scroll>

但是应用程序崩溃了.

推荐答案

在您的 TextView 中添加以下内容作为属性:

Add the following as attributes in your TextView:

android:maxLines = "1"
android:scrollbars = "vertical"

然后实例化 TextView 后,添加以下行:

Then once you have instantiated your TextView, add the line:

mTextView.setMovementMethod(new ScrollingMovementMethod());

这篇关于如何水平和垂直滚动TextView的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆