挺簡單的一個跑馬燈效果 MarqueeTextView
阿新 • • 發佈:2018-12-19
自定義TextView:
@SuppressLint("AppCompatCustomView") public class MarqueeTextView extends TextView { public MarqueeTextView(Context context) { super(context); } public MarqueeTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); } public MarqueeTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public boolean isFocused() { return true; } }
佈局檔案中引用:
<com.yjf.lottery.widget.MarqueeTextView android:id="@+id/mtv_marquee" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever" android:singleLine="true" android:text="測試測試測試測試測試測試測試測試測試測試測試測試測試測試測試" />