在android中在屏幕上滚动文本
我试图让一长段文本在屏幕上滚动,我遇到了这段代码,但是整个文本在屏幕上滚动,而不是在一行中滚动。那么我怎样才能使它以直线滚动呢在android中在屏幕上滚动文本,android,Android,我试图让一长段文本在屏幕上滚动,我遇到了这段代码,但是整个文本在屏幕上滚动,而不是在一行中滚动。那么我怎样才能使它以直线滚动呢 public class MainActivity extends Activity { TextView txtscroll; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVie
public class MainActivity extends Activity {
TextView txtscroll;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scrollable_contents);
txtscroll = (TextView) findViewById(R.id.txtscrol);
Animation translatebu = AnimationUtils.loadAnimation(this,
R.anim.animationfile);
txtscroll.setText("Some text view.");
txtscroll.startAnimation(translatebu);
ScrollView scrollable_contents = (ScrollView) findViewById(R.id.scrollableContents);
getLayoutInflater().inflate(R.layout.contents, scrollable_contents);
}
}
我将使用子字符串并在单行中显示它,您需要一个计时器。我将使用子字符串并在单行中显示它,您需要一个计时器
<translate
android:duration="5000"
android:fromXDelta="100%p"
android:repeatCount="infinite"
android:toXDelta="-100%p" />