Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android scrollview autoscrolling as text is added

Tags:

I have a scrollview containing a textview in an Android app. This textview will have text appended to it continuously at set intervals. Scrolling works and the text adds just fine, but what I'd like to do is have the scrollview autoscroll down as text is added. As new text is appended at the bottom, it automatically scrolls down to match and old text is pushed out of sight at the top. What would be even better is to add text to the bottom of the scrollview and have it push older text upward, but one thing at a time.

like image 525
AndroidHopeful Avatar asked Mar 07 '11 20:03

AndroidHopeful


People also ask

How do I turn on auto scroll?

Open the Activities overview and start typing Mouse & Touchpad. Click on Mouse & Touchpad to open the panel. In the Touchpad section, make sure the Touchpad switch is set to on. Switch the Two-finger Scrolling switch to on.

Can scroll vertically Android?

In Android, a ScrollView is a view group that is used to make vertically scrollable views. A scroll view contains a single direct child only. In order to place multiple views in the scroll view, one needs to make a view group(like LinearLayout) as a direct child and then we can define many views inside it.

What is the difference between ListView and ScrollView?

They're completely different. A ScrollView is simple a scrolling container you can use to scroll whatever you put inside it, which might be a list of items, or it might not. A ListView is very specifically designed to hold lists, where items typically look the same (or at least follow a pattern, e.g. section headings).


1 Answers

<ScrollView     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:fillViewport="true"     >     <TextView         android:id="@+id/statusText"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:layout_gravity="bottom" /> </ScrollView> 
like image 150
papaiatis Avatar answered Sep 18 '22 15:09

papaiatis