当文本变得大于文本视图的大小时如何移动文本以及如何在一行中滚动回上一个文本?

how to shift the text when it becomes bigger than the size of the textview and how to scroll back to previous text in a single line?

我正在开发一个 android 应用程序,其中的文本由 Button.Pressing 输入,该按钮将创建一个字符串,并且该字符串将显示在 textView 上,如果再次按下该按钮然后创建的字符串将被添加到 textView 上的字符串,以防多次按下按钮,创建一个长字符串,由于单个 line.only 而无法在 textview 中显示,开始的字符串将是 shown.so 我的问题是如何使单行文本视图中的旧文本消失而不是新文本消失???

我在某种程度上得到了解决方案,我可以在旧文本变大时用新文本移动 screen.but 我应该如何滚动回旧文本?? 帮帮我

你可以使用android:ellipsize="start"

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="start"
        android:maxLines="1"
        android:text="Hello World! This is a really long string on a single line meant to truncate in the beginning with an ellipse." />

然而,这不会滚动。

谷歌搜索了几个小时后....我得出了一个结果....

TextView mTextView;

在 onCreate() 内部

mTextViewT.setHorizontallyScrolling(true);
mTextViewT.setSingleLine(true);
mTextViewT.setInputType(InputType.TYPE_CLASS_NUMBER);