我正在为“语音教学”老师的期末考试准备一个项目。我有问题,请寻求帮助。我不知道问题出在哪里,为什么TextView不能向上滚动文本,并且在TextView中打印文本时不显示该句子,必须手动滚动它才能看到最新的条目。
我的代码:
<TextView
android:id="@+id/textView"
android:layout_width="340dp"
android:layout_height="300dp"
android:layout_below="@+id/progressBar1"
android:layout_centerHorizontal="true"
android:layout_marginTop="280dp"
android:ellipsize="marquee"
android:enabled="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="bottom"
android:longClickable="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollbars="vertical"
android:scrollHorizontally="false"
android:singleLine="false"
android:textIsSelectable="true" />
和
myText = (TextView) findViewById(R.id.textView);
myText.setMovementMethod(new ScrollingMovementMethod());
答案 0 :(得分:0)
尝试一下;
myText.setSelection(mtText.getText.length())
如果将其写入textWatcher,它将更加有用。
答案 1 :(得分:0)
我找到了另一个解决方案。我测试了,它有效
textView.scrollTo(0,yourSpeechText.length-1)