Auto-Scrolling Textview in Android to Bring Text into View

How can I make a TextView automatically scroll as I add more lines of text?

As per answer here Making TextView Scrollable in Android

You don't need to use a ScrollView actually.

Just set the

android:maxLines = "AN_INTEGER"

android:scrollbars = "vertical"
properties of your TextView in your layout's xml file.

Then use:

yourTextView.setMovementMethod(new ScrollingMovementMethod());

in your code.

That will work..

Auto scroll down on textviews

I already got the answer for this! Thank you for giving me some idea. I might be able to use them in the future. @Bharat Sharma, you almost got the answer! Thanks!

public void onClick(View v) {
// TODO Auto-generated method stub
log.setText(log.getText() + "\n" +input.getText());

if(log.getLineCount() > 5){
scroll_amount = scroll_amount + log.getLineHeight();
log.scrollTo(0, scroll_amount);
}
}

I called the variable scroll amount outside the onCreate(). Thanks again!

How do I enable vertical AutoScroll in a TextView (Android)

ObjectAnimator animator = ObjectAnimator.ofInt(scrollView, "scrollY", targetYScroll )
//This works by acceleration i.e start scrolling slowly before accelerating
//then starts decelerating towards the end.. I need constant scrolling

IMHO this is good solution. Use LinearInterpolator for linear scroll speed

animator.setInterpolator(new LinearInterpolator());

How to get the Android TextView to scroll down to the end automatically?

EDIT:
Use this:

    final ScrollView scroller = (ScrollView) findViewById(R.id.scroller);
scroller.setOnFocusChangeListener(new OnFocusChangeListener() {

@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
scroller.fullScroll(View.FOCUS_DOWN);
}
}
});

Android: Auto-scrolling text in TextView

In your activity you have to add if you want to marquee on text

  TextView tv=(TextView)findViewById(R.id.textview1);
tv.setSelected(true);

Automatic scrolling a text view after appending text in Android

In the XML for the textView element I would try to add:

android:gravity="bottom"

Also are you sure you need to specify android:scrollbars="vertical" in both scrollview and textview? In addition, I noticed the difference between old working version is that it doesn't uses setMovementMethod() - personally I would use this method without scrollview, but since you already have scroollview I don't see a reason why would you need it...



Related Topics



Leave a reply



Submit