AndroidTextView的跑马灯效果,解决复杂布局不能获取焦点的问题

  1. //在xml中设置以下内容
  2. android:ellipsize="marquee"  
  3.         android:focusable="true"  
  4.         android:focusableInTouchMode="true"  
自定义View实现
  1. import android.content.Context;
    import android.util.AttributeSet;
    import android.widget.TextView;
    
    /**  * Created by Dylan on 2015/10/22 0022.  * 解决复杂布局中跑马灯不能跑的问题  */ 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;
        }
    }
    



你可能感兴趣的:(android,跑马灯)