Search code examples
androidxmlscrollview

Textview Scrollview


I want to create a Textview with a scrollview. But it doesn't work.

It's just a Textview, which is centered-

Here is the xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="453dp"
android:layout_height="122dp"
android:gravity="center"
android:layout_marginLeft="40dp">

<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:fillViewport="true">



    <TextView
    android:id="@+id/text1"
    android:layout_width="453dp"
    android:layout_height="122dp"
    android:layout_gravity="left"

    android:gravity="center"
    android:text=""
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@android:color/black"
    android:textSize="16dp" 
    android:maxLines="400"


    />

   </ScrollView>
</LinearLayout> 

Solution

  • fixed scroll view height

    <ScrollView
        android:id="@+id/SCROLLER_ID"
        android:layout_width="fill_parent"
        android:layout_height="100dp"
        android:scrollbars="vertical"
        android:fillViewport="true">
    

    and make height of text View to wrap_content hope this will help