发布网友
共1个回答
热心网友
用自定义的TextView
public class AlwaysMarqueeTextView extends TextView {
public AlwaysMarqueeTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public AlwaysMarqueeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public AlwaysMarqueeTextView(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) {
if (focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if (focused)
super.onWindowFocusChanged(focused);
}
}
xml
<com.example.AlwaysMarqueeTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:text="这里是天翔灯饰的公告内容....运用文字跑马灯效果....运用文字跑马灯效果....运用文字跑马灯效果....运用文字跑马灯效果....运用文字跑马灯效果....运用文字跑马灯效果" />