当前位置:网站首页>MarqueeTextview(跑马灯)
MarqueeTextview(跑马灯)
2022-07-27 17:02:00 【Ashurol】
由于有时候TextView内容过长,实现跑马灯的状态,若一个Activity内只需一个TextView,可以为其添加以下属性
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
需要两个或多个,就要重新定义TextView类
public class MarqueeTextview extends TextView{
public MarqueeTextview(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public MarqueeTextview(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public MarqueeTextview(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
public boolean isFocused() {
// TODO Auto-generated method stub
return true;
}
}
布局文件TextView标签用包名类目代替
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.xin.marqueetextview.MainActivity" >
<com.example.xin.marqueetextview.MarqueeTextview
android:id="@+id/tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
<com.example.xin.marqueetextview.MarqueeTextview
android:layout_below="@+id/tv_1"
android:id="@+id/tv_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="@string/hello_world" />
</RelativeLayout>

边栏推荐
- HDU1171_ Big event in HDU [01 backpack]
- c语言:c语言代码风格
- Surpass Huawei? Ericsson has won more than 75 5g commercial contracts
- Debian recaptured the "debian.community" domain name, but it's still not good to stop and rest
- 【深度学习基础知识 - 48】贝叶斯网络的特点
- 【深度学习基础知识 - 47】贝叶斯网络与朴素贝叶斯
- Optimization of embedded C language for indefinite cycles
- 【深度学习基础知识 - 49】Kmeans
- 嵌入式C语言对次数固定的循环的优化
- Yanghui triangle
猜你喜欢

C language: 9. Return in main function

c语言:9、main函数中的return

C language: clion debugging method

Flink简介以及运行架构

原厂PW4203降压型1-3节锂电池充电芯片

5W奖金池/面向高校,2022法律科技创新大赛报名火热进行中

Golang sets the domestic image, vscode configures the golang development environment, and vscode debugs the golang code

IIS 发生未知FastCGI错误:0x80070005

C language: 14. Preprocessing

C language: 8. Makefile preparation
随机推荐
Count the six weapons of the domestic interface cooperation platform!
A lock faster than read-write lock. Don't get to know it quickly
揭秘高通超声波指纹被“贴膜破解”之谜
嵌入式C语言结构体
Oppo released the first AR glasses and announced that it would invest 50billion in research and development in the next three years
rxbinding
记一次无准备的实习面试
下放三星3J1传感器:代码暗示Pixel 7人脸识别安全性将大增
Can set be used to define local variables in OPDS SQL
go-zero单体服务使用泛型简化注册Handler路由
【深度学习基础知识 - 48】贝叶斯网络的特点
Fzu1669 right angled triangle
Under the heat wave of Web3.0, the ecological shock of Mensa struck
c语言:10、输入流,输出流,错误流
来一遍《剑指Offer》03. 数组中重复的数字
【华为云Stack】【大架光临】第13期:管理区解耦架构见过吗?帮政企客户搞定大难题
c语言:5、多维数组
原厂PW4203降压型1-3节锂电池充电芯片
c语言:13、指针与内存
【深度学习基础知识 - 45】机器学习中常用的距离计算方法