
图库表示框架布局的项目.
它上面有一个imageVIEw和textVIEw.
如果textVIEw中的文本太长,我需要它自动滚动.
它是一行文本,需要水平滚动.
我发现了这段代码:
TextVIEw androID:text="Single-line text vIEw that scrolls automatically" androID:singleline="true" androID:ellipsize="marquee" androID:marqueeRepeatlimit ="marquee_forever" androID:focusable="true" androID:focusableIntouchMode="true" androID:scrollHorizontally="true" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content"/>
它适用于我的测试应用程序,其中只有一个文本视图.
但它在我的画廊中不起作用.注意到,文字只是保持不动.
有帮助吗?
解决方法 试试这个自定义TextVIEw类:public class autoScrollingTextVIEw extends TextVIEw { public autoScrollingTextVIEw(Context context,AttributeSet attrs,int defStyle) { super(context,attrs,defStyle); } public autoScrollingTextVIEw(Context context,AttributeSet attrs) { super(context,attrs); } public autoScrollingTextVIEw(Context context) { super(context); } @OverrIDe protected voID onFocusChanged(boolean focused,int direction,Rect prevIoUslyFocusedRect) { if (focused) { super.onFocusChanged(focused,direction,prevIoUslyFocusedRect); } } @OverrIDe public voID onWindowFocusChanged(boolean focused) { if (focused) { super.onWindowFocusChanged(focused); } } @OverrIDe public boolean isFocused() { return true; }} 并设置以下XML属性:
androID:scrollHorizontally="true"androID:ellipsize="marquee"androID:marqueeRepeatlimit="marquee_forever"
这在我的词典应用程序中非常有效,其中多个条目可能需要同时自动滚动以显示完整内容.
总结以上是内存溢出为你收集整理的android – TextView中的自动水平滚动全部内容,希望文章能够帮你解决android – TextView中的自动水平滚动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)