My project simply contains a textView whose content is a really long text(About 200 lines of text). The user can scroll the text as they read it or simply enable auto-scrolling where they can control the speed of the auto-scroll by a seekBar.
I am not able to accomplish constant auto-scrolling of the text in the textView using a consant speed.
Below is my XML layout
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:fillViewport="true"
android:layout_below="@id/autoScrollSwitch"
android:scrollbars="vertical">
<TextView
android:id="@+id/dance_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="15sp" />
</ScrollView>
I have tried scrolling the scrollView in many different ways like;
scrollView.smoothScrollTo(0, scrollView.getBottom()); // This is too fast and not constant
This one:
ObjectAnimator animator=ObjectAnimator.ofInt(scrollView, "scrollY",targetYScroll );
animator.setDuration(8000);
animator.start(); //This works by acceleration i.e start scrolling slowly before accelerating then starts decelerating towards the end.. I need constant scrolling
How should I best achieve this?
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());