Wednesday, 23 May 2012

How to scroll TextView in Android ?


Layout:

Set the
android:maxLines = "ANY INTEGER VALUE"

android:scrollbars = "vertical"
properties of your TextView in your layout's xml file.  
<TextView
    android:id="@+id/myTextview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:singleLine="false"
    android:maxLines="3"
    android:scrollbars="vertical"
    android:textColor="#000000"
    >
</TextView>


And in the code use: 

TextView textView = (TextView)findViewById(R.id.myTextView);
textView.setMovementMethod(new ScrollingMovementMethod());

No comments:

Post a Comment