How to create a scrollable TextView in android?

By | February 15, 2012

The simplest way to create a Scrolling TextView in android is to place it inside a ScrollView.
Here is a sample xml file with a scrollable TextView.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<ScrollView
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:fillViewport="true">
	<LinearLayout
		android:layout_width="fill_parent"
		android:layout_height="fill_parent">
	<TextView android:text="sample text "
		android:id="@+id/tv"
		android:layout_width="fill_parent"
		android:layout_height="fill_parent">
	</TextView>
	</LinearLayout>
</ScrollView>
</LinearLayout>

Leave a Reply

Your email address will not be published. Required fields are marked *