Making TextView Scrollable in Android

I had a issue where the text that i wanted to display in my application was too long, thus i wanted to implement a method that lets user scroll the text to see all of it. Thus the way i did was that i used textview inside scrollview like this:

<?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:id="@+id/scrollView_ID"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="vertical"
    android:fillViewport="true">

        <TextView
        android:id="@+id/textView_ID"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1.0"/>

    </ScrollView>

</LinearLayout>

Keep checking for more tips and tricks

Tags: , ,

Leave a Reply

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

*
*