Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中在屏幕上滚动文本_Android - Fatal编程技术网

在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" />