Android TextView When the text is a long time to expect it to scroll horizontally, the following is a pro-test feasible method.
:
1. Custom TextView, override the IsFocused () method to return True to have the custom TextView always in the get focus state.
Package Com.example.shen.marqueedemo;import Android.content.context;import Android.util.attributeset;import android.widget.textview;/** * Created by Shen on 2015/8/19. */public class Marqueetextview extends TextView {public Marqueetextview (context context) { super (context); } Public Marqueetextview (context context, AttributeSet Attrs) { Super (context, attrs); } Public Marqueetextview (context context, AttributeSet attrs, int defstyleattr) { Super (context, attrs, defstyleattr) ; } @Override Public Boolean isFocused () { return true; }}
2. Layout files
Android:sigleline= "true"//single line
Android:ellipsize= "marquee"//display in the way of a marquee (animation lateral movement)
android:marqueerepeatlimit= "Marquee_forever"//Keep rolling
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "Match_ Parent " android:layout_height=" match_parent "> <com.example.shen.marqueedemo.marqueetextview Android:layout_width= "200DP" android:layout_height= "wrap_content" android:text= "hello_world! hello_ world! hello_world! " android:layout_centerinparent=" true " android:ellipsize=" marquee " android:singleline=" true " android:marqueerepeatlimit= "Marquee_forever"/></relativelayout>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android TextView Horizontal scrolling (marquee effect)