文字长度可变跑马灯效果
来源:互联网 发布:58同城网络兼职日结 编辑:程序博客网 时间:2024/06/05 15:37
布局文件属性设置
<TextView
android:id="@+id/tv_text"android:layout_width="90dp"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
android:singleLine="true" />
运行时代码
int maxWidth = getResources().getDisplayMetrics().widthPixels;
TextView textView = (TextView) findViewById(R.id.tv_text);
public void setData(String data){
float textLengthPx = textView.getPaint().measureText(data);
if(maxWidth >= textLengthPx){
data += "\t\t";
textView.getLayoutParams().width = (int) (textLengthPx);
}
textView.setText(data);
textView.requestFocus();
}
阅读全文
0 0
- 文字长度可变跑马灯效果
- 文字跑马灯效果
- 文字 跑马灯 效果
- 文字跑马灯效果
- 文字跑马灯效果
- 文字跑马灯效果
- 文字跑马灯效果
- Android 文字跑马灯效果
- Android 文字跑马灯效果
- android 文字跑马灯效果
- 文字的跑马灯效果
- 文字跑马灯效果代码
- TextView文字跑马灯效果
- 跑马灯效果 文字上下滚动效果
- 【Android】跑马灯效果(文字滚动)
- android中文字跑马灯效果
- 跑马灯效果(文字滚动)
- android 文字的跑马灯效果
- LeetCode 0088
- OpenCV基础
- Java环境变量配置
- 如何做“人”?
- spring boot项目实战之工具篇(ognl)
- 文字长度可变跑马灯效果
- phi(大数质因数分解欧拉函数)
- Solve the problem "No module named 'cv2' " in python
- Markdown
- 关于rospy 中service的理解及例子程序
- HDU 4804 Campus Design 状压DP
- Java数据结构与算法
- Java构造方法
- hamming distance(汉明距离)