【发布时间】:2020-06-12 18:36:40
【问题描述】:
我的项目只包含一个 textView,其内容是很长的文本(大约 200 行文本)。用户可以在阅读时滚动文本,也可以简单地启用自动滚动,他们可以通过 seekBar 控制自动滚动的速度。
我无法使用恒定的速度在 textView 中完成文本的持续自动滚动。
下面是我的 XML 布局
<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>
我尝试过以许多不同的方式滚动滚动视图;
scrollView.smoothScrollTo(0, scrollView.getBottom()); // This is too fast and not constant
这个:
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
我应该如何最好地做到这一点?
【问题讨论】:
标签: android android-studio textview scrollview android-animation