重写isFocused方法,让控件一直获取焦点 import android.content.Context; import android.util.AttributeSet; import android.widget.TextView; public class RollTextView extends TextView { public RollTextView(Context context) { super(context); } public RollTextView(Context context, AttributeSet attrs) { super(context, attrs); } public RollTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override public boolean isFocused() { return true; } }
<com.dofun.dofunfm.view.custom.RollTextView android:id="@+id/message" android:layout_width="500dp" android:layout_height="35dp" android:layout_centerHorizontal="true" android:textColor="@color/white" android:textSize="@dimen/home_dofun__margin_26" android:layout_marginTop="@dimen/home_dofun__margin_80" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever"/>