蹒跚走路的程序猿

Android TextView多行垂直滚动

  在Android应用中,有时候需要TextView可以垂直滚动,今天我就介绍一下怎么实现的。在布局里:

1 <TextView  
2     android:id="@+id/tvCWJ"  
3     android:layout_width="fill_parent"  
4     android:layout_height="wrap_content"  
5     android:scrollbars="vertical"   <!--垂直滚动条 -->
6     android:singleLine="false"       <!--实现多行 -->
7     android:maxLines="5"            <!--最多不超过15行 -->
8     android:textColor="#FF0000"
9     />

 然后在代码里:

1 yourTextView.setMovementMethod(ScrollingMovementMethod.getInstance());

 

posted on 2013-08-13 20:23  蹒跚走路的程序猿  阅读(1924)  评论(0编辑  收藏  举报

导航