Android TextView 可滚动 [英] Android TextView Scrollable
本文介绍了Android TextView 可滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个大小为 16 个字符的 textView,如果它超过 16 个字符,我想让它可以滚动给用户以查看剩余的字符.谁能帮帮我?
I have a textView which size is 16 characters, if it exceeds 16 characters I want to make it scrollable to the user to view remaining characters. Could any one help me?
我已经尝试过这个链接让TextView在Android上可滚动
但是没有结果?
我的 TextView 布局:
My TextView Layout:
<TextView
android:id="@+id/tv1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:maxLength="16"
android:scrollbars = "vertical"
android:ellipsize="end"
android:text="fdgdddhhhdhd"
/>
推荐答案
在你的 XML 布局文件中:
In your XML layout file:
<TextView
android:id="@+id/message_scroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:text="@string/lorem" />
在您的 Java 类文件中:
In your Java class file:
TextView tv = (TextView) rootView.findViewById(R.id.message_scroll);
tv.setMovementMethod(new ScrollingMovementMethod());
这篇关于Android TextView 可滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文