0

So, here's my promblem - I have a textview, by pressing a button it will generate new text in that textview. Because the text is bigger than textview, I need to have scroll on it. Scroll works fine, you can scroll text and read it. But there is a promblem - for example text1 is 30 lines long and text2 is 10 lines long. In textview I see text1, I scroll it to the end, then I press on button and it shows text2, but because i finished watching text1 from 30th line, I will see text2 that starts from 30th line and so I see empty space and I need to manually scroll it up. Is there way to reset scrolling parameters after generating new text?

1 Answers1

0

Please try like this.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent">

     <ScrollView 
        android:id="@+id/ScrollView01"
      android:layout_height="150px" 
      android:layout_width="fill_parent">

       <TextView 
       android:id="@+id/TEXT_VIEW" 
       android:layout_height="wrap_content" 
       android:layout_width="wrap_content" 
       android:text="This text view should act as header This text view should act as header This text view should act as header This text view should act as header This text view should act as header This text view should act as header This text view should act as header" />
     </ScrollView>
    <EditText
        android:id="@+id/EDIT_TEXT"
        android:layout_height="70px"
        android:layout_width="fill_parent"
        android:layout_alignParentBottom="true"
        android:maxHeight="70px"
    />

</RelativeLayout>

[Reference] [Scrolling a TextView]1

you can also follow auto-scrolling TextView in android to bring text into view

Best of luck!

Community
  • 1
  • 1
kablu
  • 629
  • 1
  • 7
  • 26