TextView不用ScrollViewe也可以滾動的方法


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM