关于TextView的跑马灯滚动方式
来源:互联网 发布:整容软件app 编辑:程序博客网 时间:2024/06/02 02:13
在layout里面添加TextView控件
正常的TextView里面显示文字如果过长的话文字是折叠的,但是在如果项目需求是只能在一行里显示的话,滚动无疑还算是个不错的选择
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" //单行显示文字 android:singleLine="true" //以横向滚动方向显示(需要获取焦点) android:ellipsize="marquee" // 获取焦点 android:focusable="true" //获得焦点 android:focusableInTouchMode="true" />
这个时候其实已经实现了滚动的效果,但是真实的项目中往往要比这个复杂得多,所以我们放两个来试一下
- 自定义一个TextView
首先让这个类继承TextView,之后添加` public other(Context context) { super(context); // TODO Auto-generated constructor stub}public other(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // TODO Auto-generated constructor stub}public other(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub}@Overridepublic boolean isFocused() { // TODO Auto-generated method stub return true;}`
- 使用自定义的TextView
还是之前的那个TextView我又复制了一个,把系统的TextView换成了自定义的TextView引用自定义的TextView是全包名加类名
<com.example.texttest.other android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" /> <com.example.texttest.other android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" android:singleLine="true" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" />
这样的话多行滚动就已经实现了,新人第一次写有不足的地方请多多指教,一边学习,一边把学习的成果发布出来
0 0
- 关于TextView的跑马灯滚动方式
- 一直滚动的TextView[跑马灯效果]
- 一直滚动的TextView[跑马灯效果]
- 自定义控件:滚动的TextView跑马灯
- android开发TextView自动滚动,跑马灯显示方式
- TextView 自动滚动(跑马灯)
- Textview的文字滚动,跑马灯效果的实现
- TextView跑马灯效果,也就是,自动滚动文字的效果。
- android中TextView中文本滚动的跑马灯效果
- TextView实现滚动字幕的效果【跑马灯】
- Android实现跑马灯Textview滚动效果的问题解决
- TextView的跑马灯效果为什么滚动不起来???
- android textview 跑马灯 滚动效果
- Android:TextView 自动滚动(跑马灯)
- android textview 跑马灯 滚动效果
- TextView文字横向自动滚动(跑马灯)
- android 之textview滚动,,跑马灯
- Android TextView 跑马灯滚动效果
- IOS 之 GCD线程 心得总结
- vs2005中在对话框中添加浏览网页控件及使用
- c++异常处理机制
- UGUI 之 判断鼠标或者手指是否点击在UI上
- Ext.js5表单—验证vtype扩展(时间段以及密码确认)(50)
- 关于TextView的跑马灯滚动方式
- Odoo的安装
- 学习资源
- 将MongoDB导出成csv文件
- 使用Jsoup 抓取页面的数据
- 几种功能电路的BIT测试方案设
- 分析国家统计局行政区划代码(省市区数据)生成SQL
- 浙江理工2015.12校赛-B 七龙珠
- iOS 真机测试dyld:Symbol not found:_NSArray0_