Friday, March 23, 2012

How to create a scrollable TextView in android?


How to create a scrollable TextView in android?

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.
?
Drag and copy the code
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
<?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>

No comments: