我正在開發Eclipse框架上的Android項目。在這裏我想滾動長文本在屏幕上,爲同樣我用動畫class.It工作正常,根據我的要求, 對於我在這裏分享我的代碼的參考:Android:動畫TextView有長文本顯示
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);
}
,但只是問題是,當我有很長的文字滾動的字幕,只顯示文本的某些部分,而不是整個文本。你能否給我建議最合適的解決方案,以便整個文本可以滾動爲字幕? 等待回覆... 謝謝先進。