Android走马灯

我费了好大的劲才弄好了这个

我测试了一下,在所有的布局中都能跑,就是在我的布局中 不能跑,我想是什么屏蔽了他吗,最后重写了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="这才是真正的文字跑马灯效果,文字移动速度,文字移动方向,文字移动的样式,动画等等……"
    />

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值