安卓中TextView跑马灯效果如何显示
安卓中TextView跑马灯效果怎么显示
安卓中TextView显示歌名,但有的歌名太长,想弄个跑马灯但显示不成功,不会动代码如下
请高手们看看哪里不对?
<TextView android:id="@+id/musicName"
android:maxEms = "10"
android:ellipsize = "marquee"
android:maxLines = "1"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="25dip"
android:text="">
</TextView>
TextView能内容是动态添加的
------解决方案--------------------
用这个就可以实现了
安卓中TextView显示歌名,但有的歌名太长,想弄个跑马灯但显示不成功,不会动代码如下
请高手们看看哪里不对?
<TextView android:id="@+id/musicName"
android:maxEms = "10"
android:ellipsize = "marquee"
android:maxLines = "1"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="25dip"
android:text="">
</TextView>
TextView能内容是动态添加的
------解决方案--------------------
public class AlwaysMarqueeTextView extends TextView {
public AlwaysMarqueeTextView(Context context) {
super(context);
}
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;
}
}
用这个就可以实现了