AndroidStudio——TextView文字左右滚动(跑马灯效果)无效解决办法
来源:互联网 发布:定时任务软件 编辑:程序博客网 时间:2024/05/20 20:18
TextView文本文字的左右滚动效果(跑马灯)的两种方式:
一、在布局文件中设置相应的焦点
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:focusable="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:text="**********"/>二、继承AppCompatTextView,继承控件的三个方法,重写isFocused()方法,然后在布局文件中引用自定义控件的完整路径名
public class MyTextView extends AppCompatTextView { public HomeTextView(Context context) { super(context); } public HomeTextView(Context context, AttributeSet attrs) { super(context, attrs); } public HomeTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override public boolean isFocused() { return true; }}
<com.demo.ui.MyTextView android:layout_width="match_parent" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" android:text="**********"/>重点:必须使用android:singleLine="true"
不可以用android:maxLines="1" 或 android:lines="1"代替,
代替之后就不会有滚动效果了,虽然会报这个警告......:
android:singleLine
is deprecated: UsemaxLines="1"
instead less... (Ctrl+F1)
Deprecated views, attributes and so on are deprecated because there is a better way to do something. Do it that new way. You've been warned.
1 0
- AndroidStudio——TextView文字左右滚动(跑马灯效果)无效解决办法
- TextView 文字滚动 跑马灯效果
- TextView文字横向滚动(跑马灯效果)
- TextView实现跑马灯效果(文字滚动)
- TextView跑马灯效果,也就是,自动滚动文字的效果。
- Textview的文字滚动,跑马灯效果的实现
- 一分钟实现 Android textview 跑马灯文字滚动效果
- 自定义View—实现滚动TextView(跑马灯)效果
- TextView文字跑马灯效果
- 【Android】跑马灯效果(文字滚动)
- 跑马灯效果(文字滚动)
- --------------------【Android】跑马灯效果(文字滚动)
- adnroid textview设置文字横向自动滚动(跑马灯效果)
- TextView文字横向自动滚动(跑马灯)
- TextView跑马灯无效的解决办法
- 跑马灯效果 文字上下滚动效果
- Android TextView 横向滚动(跑马灯效果)
- Android 小样之TextView横向滚动(跑马灯效果)
- 数字图像基础理论:频谱vs功率谱vs能谱
- bzoj1477青蛙的约会
- Android抓包方法(一) 之Fiddler代理
- 自学Qt之路——串口编程(使用第三方提供的类)
- 【C#】执行费时操作时提醒框的添加(开线程)
- AndroidStudio——TextView文字左右滚动(跑马灯效果)无效解决办法
- 欧几里得拓展算法求模逆元
- Android抓包方法(二) 之Tcpdump命令+Wireshark
- okHttp+protobuf实现okhttp post二进制流至服务器
- 机械臂建模与仿真(三):模拟环境测试moveit
- 《C++ primer plus》第十六章:string类和标准模板库(二) 学习笔记
- L1-02 打印沙漏
- 理解pages和page Frames的区别
- QString与String相互转换