For example, I have a layout like this:
<ScrollView> <LinearLayout> <LinearLayout> ... </LinearLayout> <LinearLayout> ... </LinearLayout> <LinearLayout> <TextView> </TextView> </LinearLayout> </LinearLayout> </ScrollView>
My TextView has long content. Now I can scroll the ScrollView manually to the end of the contents of the TextView. In the code I write: scrview.scrollTo(0, 800); , with scview is my ScrollView. It should scroll to the middle of the contents of the TextView. But at startup, it scrolls to the beginning of the TextView and cannot scroll the contents of the TextView.
Does anyone know what causes these problems?
EDIT: I found it. Looks like I'm calling scrollTo too soon. Using
scrview.post(new Runnable() { public void run() { scrview.scrollTo(0, 800); } });
and it works. A posted response for anyone receiving the same issue.
user1417127
source share