Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Ellipsize marquee is not working except on the first item

I am trying to design a staggered layout manager for recycler view and each item of the recycler view inflates a cardview. The problem is whenever I try to apply marquee in my item, the only first item gets the expected marquee behavior and other items remain static. Isn't it supposed to be applied to every item?

I have followed this

XML

<TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/job_clicktoseedetails"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/job_deadline"
                android:text="Click To See The Details of the job"
                android:textColor="@android:color/holo_blue_dark"
                android:paddingBottom="5dp"
                android:paddingRight="5dp"
                style="@style/Widget.SampleMessageTile"
                />

Styles.xml

<style name="Widget.SampleMessageTile">

        <item name="android:singleLine">true</item>
        <item name="android:ellipsize">marquee</item>
        <item name="android:marqueeRepeatLimit">marquee_forever</item>
        <item name="android:focusable">true</item>
        <item name="android:focusableInTouchMode">true</item>
        <item name="android:scrollHorizontally">true</item>
    </style>

enter image description here

like image 452
Aveek Avatar asked Nov 27 '25 07:11

Aveek


2 Answers

To start the marquee in TextView, it need to be focused, and I guess that only your first CardView is getting focus.

Try something like this:

public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position){
   viewHolder.yourText.setSelect(true);
}

I hope that solve the problem.

like image 103
EndriusSol7 Avatar answered Nov 29 '25 19:11

EndriusSol7


In your xml file in textView tag write following code

android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:ellipsize="marquee"

and in adapter write down

viewHolder.yourText.setSelect(true);
like image 33
Swapnil Kshirsagar Avatar answered Nov 29 '25 21:11

Swapnil Kshirsagar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!