3

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

Aveek
  • 849
  • 1
  • 12
  • 28

2 Answers2

2

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.

2

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);
Pranav Karnik
  • 3,318
  • 3
  • 35
  • 47