用textview实现跑马灯的效果;
<com.example.dialoge.MyTextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:singleLine="true"
android:focusable="true"
android:ellipsize="marquee"
android:focusableInTouchMode="true"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
package com.example.dialoge;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewDebug.ExportedProperty;
import android.widget.TextView;
public class MyTextView extends TextView {
public MyTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public MyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
@ExportedProperty(category = "focus")
public boolean isFocused() {
// TODO Auto-generated method stub
return true;
}
}
本文介绍了一种使用自定义TextView实现跑马灯效果的方法。通过设置TextView的属性如singleLine为true、ellipsize为marquee等,使得文本能在屏幕上滚动显示。此外,还提供了一个名为MyTextView的自定义视图类的具体实现。
602

被折叠的 条评论
为什么被折叠?



