您的位置:首页 > 移动开发 > Android开发

android 文字太长跑马灯获不到焦点无法显示效果的一种解决方法

2015-05-07 12:00 639 查看
自定义一个类

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="这才是真正的文字跑马灯效果,文字移动速度,文字移动方向,文字移动的样式,动画等等……"

/>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐