首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

TextView不要ScrollViewe也可以滚动

2012-08-26 
TextView不用ScrollViewe也可以滚动java 代码TextView textview (TextView) findViewById(R.id.text)??

TextView不用ScrollViewe也可以滚动

java 代码

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>

热点排行