我費了好大的勁才弄好了這個
我測試了一下,在所有的布局中都能跑,就是在我的布局中 不能跑,我想是什麼屏蔽了他嗎,最後重寫了TextView才可以了就是網上
大家們說的哪個方法:
public class MarqueeText extends TextView {
public MarqueeText(Context con) {
super(con);
}
public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MarqueeText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean isFocused() {
return true;
}
@Override
protected void onFocusChanged(boolean focused, int direction,
Rect previouslyFocusedRect) {
}
}
大家用這個是解決失去焦點後不能跑的問題,我的這個是因為從未獲得焦點所以一直沒有跑!
<com.example.MarqueeText
android:id="@+id/AMTV1"
android:layout_width="400dip"
android:layout_height="wrap_content"
android:layout_marginLeft="80dip"
android:textSize="25sp"
android:textColor="@android:color/black"
android:lines="1"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:background="#2FFFFFFF"
android:text="這才是真正的文字跑馬燈效果,文字移動速度,文字移動方向,文字移動的樣式,動畫等等……"
/>