How to make TextView in android scrollable?

A TextView cannot be scrollable by default. It needs to be in a scroll view tag in the xml file in layout folder. Following code snippet will help you fix the issue:

Copy the following code snippet in your xml file in layout:

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_height=”wrap_content” android:orientation=”vertical” android:id=”@+id/relativeLayout1″ android:layout_width=”match_parent”>

<ScrollView android:visibility=”visible” android:layout_height=”335dip” android:layout_width=”match_parent” android:keepScreenOn=”true” android:scrollbarStyle=”insideInset” android:id=”@+id/scrollView1″ android:scrollbars=”vertical” >
<TextView android:text=”The wesite text will be displayed here” android:isScrollContainer=”true” android:layout_width=”fill_parent” android:id=”@+id/pagetext” android:scrollbars=”vertical” android:layout_gravity=”top” android:keepScreenOn=”true” android:layout_height=”match_parent”></TextView>
</ScrollView>

<TableRow android:layout_alignParentLeft=”true” android:layout_height=”wrap_content” android:id=”@+id/tableRow1″ android:layout_width=”match_parent” android:layout_alignParentBottom=”true”>
<EditText android:text=”EditText” android:layout_height=”wrap_content” android:id=”@+id/editText1″ android:layout_width=”200dip”></EditText>

<Button android:text=”@string/read” android:id=”@+id/button1″ android:layout_height=”wrap_content” android:layout_width=”wrap_content” android:onClick=”myClickHandler”></Button>
</TableRow>

</RelativeLayout>

Originally posted 2011-10-27 12:48:55.

This entry was posted in Android and tagged , , , , . Bookmark the permalink.

Leave a Reply