android 讓 TextView 自帶滾動條


一、Xml代碼

  1. <TextView  
  2.     android:id="@+id/textview"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="wrap_content"  
  5.     android:singleLine="false"  
  6.     android:maxLines="5"  
  7.     android:scrollbars="vertical"  
  8.     />

二、還需要在代碼中設置 TextView 相應的方法

  1. TextView textView = (TextView)findViewById(R.id.text_view);   
  2. textView.setMovementMethod(ScrollingMovementMethod.getInstance()); 

好了,大功告成。


免責聲明!

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



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