ScrollView alawys scrolling to the bottom

Posted by Sebi on Stack Overflow See other posts from Stack Overflow or by Sebi
Published on 2010-05-14T08:13:52Z Indexed on 2010/05/14 8:14 UTC
Read the original article Hit count: 481

Filed under:
|
|

I defined a scrollview with a texteedit in my layout:

 <ScrollView android:fillViewport="true"
     android:layout_marginBottom="50dip"
     android:id="@+id/start_scroller"
     android:layout_height="fill_parent"
     android:layout_width="fill_parent"
     android:fadingEdge="none">
 <TextView  
    android:id="@+id/text"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" >
 </TextView>
 </ScrollView>

I add text to this ScrollView with the following method:

public void writeToLogView(String textMsg) {
   if (text.getText().equals("")) {
       text.append(textMsg);
   } else {
    text.append("\n" + textMsg);
    scroller.scrollBy(0, 1000000);
   }
}

As you can see i append the text and try to scroll to the bottom of the ScrollView. Unfortunately this doesn't worked correctly. It scrolls down, but not always, and not always to the bottom. Any hints?

© Stack Overflow or respective owner

Related posts about java

Related posts about android