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

Android程序:文字跑马灯实现方法

2015-03-24 17:40 465 查看
先新建一个继承textview的MarqueeText的类

public class MarqueeText extends TextView {

public MarqueeText(Context context) {
super(context);

}

public MarqueeText(Context context, AttributeSet attrs) {
super(context, attrs);
}

public MarqueeText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}

@Override
public boolean isFocused() {
return true;
}
}

然后引用这个类创建textview
<com.example.chris.paomadengtextview.MarqueeText
android:id="@+id/textview1"
android:text="@string/hello_world"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:ellipsize="marquee" />
<com.example.chris.paomadengtextview.MarqueeText
android:id="@+id/textview2"
android:layout_below="@+id/textview1"
android:layout_marginTop="10dp"
android:text="@string/hello_world"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:ellipsize="marquee" />
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: