我正在开发在 Eclipse 框架上开发的 Android 项目。在这里我想在屏幕上滚动长文本,因为我使用了 Animation 类。它按照我的要求工作得很好,作为参考,我在这里分享我的代码:
TextView tt = new TextView (this);
tt.setText("Welcome Here is my very long text to display.But only some part of text is getting displayed, not the entire text.Please provide me the solution so that entire text should be displayed on the screen");
tt.setEllipsize(TextUtils.TruncateAt.valueOf("MARQUEE"));
tt.setTextSize(40);
tt.setSingleLine(true);
//here actual_scr_width = device screen width
//here actual_scr_height = device screen height
if(direction.equalsIgnoreCase("left"))
{
Animation animationToLeft = new TranslateAnimation(actual_scr_width, -actual_scr_width, 0, 0);
animationToLeft.setDuration(12000);
animationToLeft.setRepeatMode(Animation.RESTART);
animationToLeft.setRepeatCount(Animation.INFINITE);
tt.setAnimation(animationToLeft);
}
else if(direction.equalsIgnoreCase("right"))
{
Animation animationToLeft = new TranslateAnimation(-actual_scr_width, actual_scr_width, 0, 0);
animationToLeft.setDuration(12000);
animationToLeft.setRepeatMode(Animation.RESTART);
animationToLeft.setRepeatCount(Animation.INFINITE);
tt.setAnimation(animationToRight);
}
但唯一的问题是,当我将长文本滚动为选框时,它只显示文本的某些部分,而不是整个文本。您能否建议我最合适的解决方案,以便整个文本可以滚动为选框?等待回复...在此先感谢。