Android TextView跑马灯效果
来源:互联网 发布:mysql bit类型比较函数 编辑:程序博客网 时间:2024/04/30 12:25
以前在调TextVie的跑马灯效果的时候,总没有成功,网上很多人都说是TextView没有获取焦点导致。
以下效果再android4.4上测试:
1------最基本的跑马灯xml---无效果----
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
2-------点击才有效果-----------
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:clickable="true"
3.--------无效果-------
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
4.--------最理想最完美实现跑马灯,采用重载TextView-------
<bluetoothsoc.serialport.view.ScrollingTextView android:id="@+id/albumname"
android:textSize="30sp"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
package bluetoothsoc.serialport.view;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;
public class ScrollingTextView extends TextView {
public ScrollingTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public ScrollingTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ScrollingTextView(Context context) {
super(context);
}
@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);
}
@Override
public boolean isFocused() {
return true;
}
}
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- [Android]TextView跑马灯效果
- Android textView 跑马灯效果
- android TextView 跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- android TextView跑马灯效果
- android TextView跑马灯效果
- Android TextView跑马灯效果
- Android TextView跑马灯效果
- android textView跑马灯效果
- Android TextView 跑马灯效果
- Android TextView跑马灯效果
- android textview 跑马灯效果
- hibernate save和update以及saveOrUpdate区别
- Linux crontab定时执行任务
- Html+Css+base标签是什么及其作用介绍
- 用户画像数据建模方法
- viewpagerindicator+UnderlinePageIndicator+ viewpage切换
- Android TextView跑马灯效果
- SSH:EL表达式讲解
- yuv转rgb
- Android NDK中使用socket
- ClassName::class
- java从文本文件中一次读入一行数据进行处理
- Linux 下Flume1.4.0的安装
- UFT/QTP的工作原理
- 安卓VideoView使用