How to add marquee effect to listview?

爱⌒轻易说出口 提交于 2020-01-11 13:07:56

问题


I have list of my friends in ArrayList & i am trying to display it in listview using ArrayAdapter & rowlayout.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/rowlayout"
android:padding="10dp"
>

Now i want to add marquee effect to it.I want to scroll this listview forever. For this i added following code

android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingLeft="15dip"
android:paddingRight="15dip"
android:scrollHorizontally="true"
android:singleLine="true"

But this code stop my OnLongClickListner effect of listview.

I don't know why?


回答1:


   android:ellipsize="marquee"
            android:gravity="left"
            android:lines="1"
            android:scrollHorizontally="true"

android:singleLine is depricated,focusable -not needed too

This layout works in a new sample project:

<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" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="marquee_forever"
        android:paddingLeft="15dip"
        android:paddingRight="15dip"
        android:scrollHorizontally="true"
        android:text="12312312321321312312321321312311321321321312321312312123132132132" />

</RelativeLayout>


来源:https://stackoverflow.com/questions/12525760/how-to-add-marquee-effect-to-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!