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" />
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" />
相关文章推荐
- Android 文字自动滚动(跑马灯)效果的两种实现方法
- Android 文字自动滚动(跑马灯)效果的两种实现方法
- Android 文字自动滚动(跑马灯)效果的两种实现方法
- Android 文字自动滚动(跑马灯)效果的两种实现方法
- Android 文字自动滚动(跑马灯)效果的两种实现方法[特别好使]
- Android 文字自动滚动(跑马灯)效果的两种实现方法[特别好使]
- Android 文字自动滚动(跑马灯)效果的两种实现方法
- Android 文字自动滚动(跑马灯)效果的两种实现方法
- Android 文字自动滚动(跑马灯)效果的两种实现方法
- Android 按后退键退出Android程序的实现方法
- Android自定义“图片+文字”控件四种实现方法
- Android开发实现开机自动运行程序的方法
- android TextView不用获得焦点实现跑马灯效果 两种方法
- Android中再按一次返回键退出程序的实现(返回桌面)两种方法
- Android中“再按一次退出程序”的实现方法
- Android双击返回键退出程序的实现方法
- Android实现文字显示跑马灯效果
- Android双击返回键退出程序的实现方法
- Android自定义“图片+文字”控件四种实现方法之 二--------个人最推荐的一种
- Android自定义“图片+文字”控件实现方法之 --------个人最推荐的一种