TextView 走马灯效果

来源:互联网 发布:php开源商城源码下载 编辑:程序博客网 时间:2024/05/29 07:28

一般实现:

<TextView             android:id="@+id/menu_desc"             android:layout_width="fill_parent"             android:layout_height="wrap_content"             android:text="TextView 走马灯效果TextView 走马灯效果TextView 走马灯效果TextView 走马灯效果TextView 走马灯效果"             android:singleLine="true"             android:ellipsize="marquee"             android:focusable="true"             android:focusableInTouchMode="true"             android:scrollHorizontally="true"             android:marqueeRepeatLimit="marquee_forever"             >          </TextView>        

实际上就是加上了这5行代码:

             android:singleLine="true"             android:ellipsize="marquee"             android:focusable="true"             android:focusableInTouchMode="true"             android:scrollHorizontally="true"             android:marqueeRepeatLimit="marquee_forever"

**

实现不了?

**
1、看看是不是有控件抢焦点了,比如EditText之类的,将他们的focusable设为false,android:focusable=”false”。比如说下面的:

 <EditText                    android:layout_width="fill_parent"                    android:layout_height="fill_parent"                    android:background="@null"                    android:textSize="13sp"                    android:lines="1"                    android:focusable="false"                    android:singleLine="true"                    android:gravity="center_vertical"                    android:textColor="@color/gray"                    android:imeOptions="actionDone"                    />

2、在列表中显示跑马灯效果,要在代码中设置该TextView的selected为true
textView.setSelected(true);
3、以上都设置了呀,仍然没显示跑马灯效果。我遇到的一种很坑可能,TextView设置成fill_parent或是很长,但是由于text设置的字数不够长,就当成普通文本一样显示,无效果了。

这里写图片描述

0 0
原创粉丝点击