2016-04-12 63 views
1

我想在屏幕上滚动一段文字,我遇到过这段代码,但是整个文本在屏幕上滚动而不是滚动到一行。那么我怎样才能让它直线滚动?滚动屏幕上的文字在android中

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

回答

0

我会用子和一行显示它,你需要为这个计时器。