android TextView不用ScrollViewe也可以滚动的方法
代码
textview textview = (textview) findviewbyid(r.id.text);
/** *
* 只有调用了该方法,textview才能不依赖于scrollview而实现滚动的效果。
* 要在xml中设置textview的textcolor,否则,当textview被触摸时,会灰掉。
*/
textview.setmovementmethod(scrollingmovementmethod.getinstance());
xml文件
<textview
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textsize="18sp"
android:scrollbars="vertical"
android:maxlines="12"
android:textcolor="@color/white"
android:text="@string/str"
android:id="@+id/text"
></textview>
如对本文有疑问,
点击进行留言回复!!
网友评论