怎样才能让我添加更多的行文字的TextView的自动滚动? [英] How can I make a TextView automatically scroll as I add more lines of text?

查看:410
本文介绍了怎样才能让我添加更多的行文字的TextView的自动滚动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有一个TextView像这样:

So, I have a TextView like so:

<TextView
    android:layout_width="fill_parent"
    android:layout_height="140.7dp"
    android:id="@+id/terminalOutput"
    android:layout_marginBottom="0.0dp"
    android:scrollbars="vertical"
    android:scrollbarAlwaysDrawVerticalTrack="true"
    android:maxLines="8" />

我用它作为一种运行日志的,显示给用户的,这样他们可以监视任务,需要约3分钟的进展。但是,一旦我去了8行,文本熄灭屏幕。这是直观的用户,因为他们没有办法知道它去了屏幕,比其他通过试图向下滚动手动轮询。

I use it as a sort of running log, displayed to the user so they can monitor progress of a task that takes about 3 minutes. However, once I go over 8 lines, the text goes off screen. This is unintuitive to the user because they have no way of knowing that it went off screen, other than to manually poll by trying scroll down.

我怎样才能让这个每次我添加一些文本到这个TextView的我做它向下滚动低,因为它可以去?

How can I make it so that every time I add some text to this TextView I make it scroll down as low as it can go?

此外,这是在Xamarin的Andr​​oid,但我不认为这是相关的。这很容易就和Java之间的转换

Also, this is in Xamarin Android, but I don't think it's relevant. It's easy to translate between it and Java

推荐答案

根据这里的回答在Android的制作的TextView滚动

As per answer here Making TextView Scrollable in Android

您无需使用滚动型实际。

You don't need to use a ScrollView actually.

只需设置

安卓MAXLINES =AN_INTEGER

android:maxLines = "AN_INTEGER"

安卓滚动条=垂直   在您的布局的XML文件中的TextView的属性。

android:scrollbars = "vertical" properties of your TextView in your layout's xml file.

然后使用:

yourTextView.setMovementMethod(新ScrollingMovementMethod())

yourTextView.setMovementMethod(new ScrollingMovementMethod())

在你的code。

这会工作..

这篇关于怎样才能让我添加更多的行文字的TextView的自动滚动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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