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
How to Set "Android:Layout_Below" at Runtime Programmatically
Android Gcm: Same Sender Id for More Application
Spannablestringbuilder to Create String with Multiple Fonts/Text Sizes etc Example
Findclass from Any Thread in Android Jni
Android N Requires the Ide to Be Running with Java 1.8 or Later
How to Know When the Recyclerview Has Finished Laying Down the Items
Upgrade Realm in an Android Project
Android Webview Loading Data Performance Very Slow
Share Image and Text Through Whatsapp or Facebook
Session 'App': Error Launching Activity
Textinputlayout Not Showing Edittext Hint Before User Focus on It
Android: How to Set the Zoom Level of Map View to 1 Km Radius Around My Current Location
Using Listview:How to Add a Header View
Android Toggle Button Custom Look
Android Resources$Notfoundexception: Resource Id #0X7F030027
Configuration with Name 'Default' Not Found. Android Studio
Android - Switch Tabs from Within an Activity Within a Tab
How to Join Png with Alpha/Transparency in a Frame in Realtime