【发布时间】: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