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

Android textview 不使用ScrollView也可滚动的方法

2015-08-17 09:22 681 查看
转载自:http://www.jb51.net/article/43377.htm
http://407827531.iteye.com/blog/1558853
<pre name="code" class="java">TextView textview = (TextView) findViewById(R.id.text);
/**             *
* 只有调用了该方法,TextView才能不依赖于ScrollView而实现滚动的效果。
* 要在XML中设置TextView的textcolor,否则,当TextView被触摸时,会灰掉。
*/

textview.setMovementMethod(ScrollingMovementMethod.getInstance());




<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:scrollbars="vertical"
android:maxLines="12"
android:textColor="@color/white"
android:id="@+id/text"
android:text="hello world"
 ></TextView>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: