【问题标题】:Scroll text across screen in android在android中跨屏幕滚动文本
【发布时间】:2016-04-12 22:58:54
【问题描述】:

我正在尝试让长文本在屏幕上滚动,我遇到了这段代码,但是整个文本在屏幕上滚动而不是单行滚动。那么我怎样才能让它直线滚动呢?

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

【问题讨论】:

    标签: android


    【解决方案1】:

    我会使用子字符串并将其显示在一行中,您需要一个计时器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多