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..
Need to make TextView scroll vertically automatically
You shouldn't put vertically scrollable component inside vertically scrollable scrollview, and since your textview is scrollable, i don't see why you need the scrollview in the first place.
Then you can use text.setScrollY(text.getLayout().getHeight()). I'm not sure if it will work, but if it doesn't you can try Get the size of a text in TextView
Making TextView scrollable on Android
You don't need to use a ScrollView
actually.
Just set the
android:scrollbars = "vertical"
properties of your TextView
in your layout's xml file.
Then use:
yourTextView.setMovementMethod(new ScrollingMovementMethod());
in your code.
Bingo, it scrolls!
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());
Android automatic horizontally scrolling TextView
If you don't need to sub-class the TextView
, you can try this in your layout file:
<TextView
android:text="Single-line text view that scrolls automatically if the text is too long to fit in the widget"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Also, in your code use the following:
findViewById(R.id.serviceColorCode).setSelected(true);
[Answer edited based on comments]
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);
}
}
});
How to display multiple lines of text with scrolling in android?
You can limit the Height of TextView
to match the number of lines you user wants to see, then simply put your TextView
in a ScrollView
I had done a simple example to demonstrate this...
<ScrollView android:layout_height="30dp"
android:layout_width="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:textSize="16sp"
android:id="@+id/tv1"
/>
</ScrollView>
Related Topics
How to Close the Current Fragment by Using Button Like the Back Button
Photo Rotated from Camera (Samsung Device)
Android: Open a Pdf from My App Using the Built in Pdf Viewer
Possible Unhandled Promise Rejection (Id:0) Error: Network Error in React Native
How to Avoid Overlap View in Relative Layout in Android
Error: Open Failed: Enoent (No Such File or Directory)
Setting Onclicklistener for the Drawable Right of an Edittext
Android Notification Has a Color Icon Instead of Being Turned White
Android Fastboot Devices Not Returning Device
How to Add a Library Project to Android Studio
How to Make a Textview Automatically Scroll as I Add More Lines of Text
How to Capitalize the First Letter of Text in a Textview in an Android Application
Force Override Camera Image on Android
How to Enable Location Access Programmatically in Android
Android Volley Basicnetwork.Performrequest() Unexpected Response Code 404
Textview With Too Long Strings