转自: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>

 

相关文章:

  • 2021-06-15
  • 2022-12-23
  • 2021-12-19
  • 2022-03-10
  • 2021-07-20
  • 2021-06-17
  • 2021-12-17
  • 2022-01-02
猜你喜欢
  • 2021-06-05
  • 2022-12-23
  • 2022-02-16
  • 2022-02-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
相关资源
相似解决方案