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()); 

好了,大功告成。

posted on 2012-08-21 17:03  jxgxy  阅读(14641)  评论(0编辑  收藏  举报

导航