Implementation method of Android TextView Running Horse lamp effect

  • 2021-01-02 21:59:12
  • OfStack

This paper describes the Android TextView running horse lamp effect implementation method. To share for your reference, the details are as follows:


public class MyTextView extends TextView{
  public MyTextView(Context context, AttributeSet attrs) {
    super(context, attrs);
    // TODO Auto-generated constructor stub
  }
  public MyTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    // TODO Auto-generated constructor stub
  }
  public MyTextView(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
  }
  @Override
  public boolean isFocused() {
    // TODO Auto-generated method stub
    return true;   //must be return true;
  }
}

In the xml file:


<packagename.MyTextView android:id="@+id/my_textview"
android:layout_width="400px" android:layout_height="35px" 
android:singleLine="true" android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever" android:textSize="22sp"/>

For more information about Android controls, please refer to our special topic: Summary of Android Controls usage

I hope this article has been helpful in Android programming.


Related articles: