TextView实现滚动的三种方式:
1、嵌套在ScrollView或者HorizontalScrollView中
垂直滚动:
<scrollview android:layout_width="fill_parent"
android:layout_height="fill_parent" android:scrollbars="vertical">
<textview android:text="http://orgcent.com …"/>
</scrollview>
<scrollview android:layout_width="fill_parent"
android:layout_height="fill_parent" android:scrollbars="vertical">
<textview android:text="http://orgcent.com …"/>
</scrollview>
水平滚动:使用标签<horizontalscrollview></horizontalscrollview>
一定要注意的是 ScrollView要放到 textView外边 才能生效地 。
2、设置ScrollingMovementMethod
代码中添加:
TextView.setMovementMethod(new ScrollingMovementMethod());
XML中配置:
android:scrollbars="vertical"
特别要注意 2条件同时满足才能效。
3、使用Scroller来自定义TextView
点击查看:android自定义View-垂直滚动的TextView
如果需要删除TextView的 滚动条 可以 设置ScrollView 的xml的属性 android:scrollbars="none"