ListView 中Item TextView 跑马灯遇到的问题

来源:互联网 发布:素材下载站源码 编辑:程序博客网 时间:2024/05/18 00:24

单独的使用textView 做成跑马灯效果,你只需要这样做:

   <TextView       android:id="@+id/test"        android:layout_width="match_parent"        android:layout_height="wrap_content"              android:layout_marginRight="5dp"        android:focusable="true"        android:ellipsize="marquee"        android:minWidth="180dp"        android:singleLine="true"                    android:marqueeRepeatLimit="marquee_forever"         android:focusableInTouchMode="true"         android:text="aslkdsjflas;djfalsdjfalsdfjdsafas;dfjasdfasdflaksj"        android:textColor="#8e8e8e"        android:textSize="16dip" />
它的layout_width 一定不能是wrap_content 。要么固定宽度,要么match_parent。也必须设置焦点
   android:focusable="true"。
但是当你在ListView里设置这样的效果的时候,还要多做两件事,一是在ListView里也要设置  android:focusable="true"
<pre name="code" class="html"> <ListView        android:id="@+id/list"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_below="@id/test"        android:focusable="true"        />
adapter 还要设置此TextView.setSelected(true);这样才会生效!

android QQ交流:1013896293 

0 0
原创粉丝点击