我已经成功地启用了Android TextView的滚动功能,方法是将其放在ScrollView中,或者使用TextView的setMovementMethod (例如,myTextView.setMovementMethod(new ScrollingMovementMethod( ) );)。
不过,理想情况下,我希望看到TextView的滚动效果类似于IPhone/IPod touch的滚动效果,即文字会超调并反弹回来。在模拟器中,TextView只是滚动到开头或结尾,没有任何动画效果。
有没有一种简单的方法来启用这种滚动行为,或者使用安卓的动画功能和OvershootInterpolator的其他方法?
发布于 2013-08-08 05:40:52
听起来默认的ListView行为可能就是您想要的。在可扩展标记语言中定义ListView,然后设置一个在TextView中馈送的自定义适配器。
<ListView android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>ListView文档:http://developer.android.com/reference/android/widget/ListView.html
您可以看到有一个OnOverScrolled方法。默认情况下,它应该可以工作。
发布于 2016-01-09 14:40:38
对于完整的TextView滚动,我们可以将#franta指定的代码编辑为以下代码
private void animateTextView() {
int textWidth = getTextViewWidth(txtLastLocation);
int displayWidth = Device.getDisplayWidth(getContext());
if((displayWidth)<=textWidth) {
textViewAnimation = new TranslateAnimation(
textWidth, -textWidth,
0, 0);
textViewAnimation.setDuration(10000); // Set custom duration.
textViewAnimation.setStartOffset(0);// Set custom offset.
textViewAnimation.setRepeatMode(Animation.RESTART); // This will animate text back ater it reaches end.
textViewAnimation.setRepeatCount(Animation.INFINITE); // Infinite animation.
mTextView.startAnimation(textViewAnimation);
}
}https://stackoverflow.com/questions/3799406
复制相似问题