如何在Android中获取TextView具有水平滚动和自动滚动?

问题描述:

我想要一个简单的水平滚动TextView,我知道我使用Horizo​​ntalScrollview,我希望文本被连续自动滚动。那可能吗?如何在Android中获取TextView具有水平滚动和自动滚动?

你可以使用Android:在TextView的属性ellipsize =“选取框”或实现自己的动画

+3

一个侧面说明:只有被选中TextView的默认字幕动画开始。 – 2010-06-03 20:05:25

这是简单地使用XML自动滚动文本视图小例子,无需对码的Java。希望你会喜欢!试试你自己,这是很容易执行

试试这个:

<TextView 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:singleLine="true" 
android:scrollHorizontally="true" 
android:ellipsize="marquee" 
android:marqueeRepeatLimit ="marquee_forever" 
android:focusable="true" 
android:focusableInTouchMode="true" 
android:text="This is small example for auto scroll text view simply using XML, no need to code Java. Hope you like it! Try it on your own, it is very easy to perform" /> 

Click here to see the Output

这里文本会自动滚动,你会得到无限滚动。玩的开心!

Click here to see detailed tutorial