Prathamesh Talathi
Prathamesh Talathi

Reputation: 195

How to add marquee effect to listview?

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?

Upvotes: 0

Views: 4096

Answers (1)

Yahor10
Yahor10

Reputation: 2132

   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>

Upvotes: 1

Related Questions