轉自:http://www.jb51.net/article/43377.htm
android TextView不用ScrollViewe也可以滾動的方法。
TextView textview = (TextView) findViewById(R.id.text);
/** *
* 只有調用了該方法,TextView才能不依賴於ScrollView而實現滾動的效果。
* 要在XML中設置TextView的textcolor,否則,當TextView被觸摸時,會灰掉。
*/
textview.setMovementMethod(ScrollingMovementMethod.getInstance());
xml:
1 <TextView 2 xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="fill_parent" 4 android:layout_height="wrap_content" 5 android:textSize="18sp" 6 android:scrollbars="vertical" 7 android:maxLines="12" 8 android:textColor="@color/white" 9 android:text="@string/str" 10 android:id="@+id/text" 11 ></TextView>