您的位置:首页 > 移动开发 > Android开发

android TextView不用ScrollViewe也可以滚动的方法

2014-09-25 15:02 225 查看
这篇文章主要介绍了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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: