i am begginer in android. In my app i am having textview which has multiple lines of text , it may have 15-20 lines. i want vertical auto scroll of text within that textview. so what can be the solution?
here is my xml code :
<LinearLayout
android:id="@+id/Thumbnail"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:gravity="center"
android:background="@drawable/imgres">
<ScrollView
android:id="@+id/sv"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:background="#80000000"
android:width="200dp"
android:textStyle="bold"
android:textColor="#ffffff"
android:gravity="center"
android:layout_alignParentTop="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollbars = "vertical"
android:maxLines="10"
/>
</ScrollView>
</LinearLayout>
In function i have set the text of my textview using code below :
tv.setText(textArray);
You don’t need to use a ScrollView actually.
Just set the
properties of your TextView in your layout’s xml file.
Then use:
in your code.