Reputation: 1576
i have a recycler view having item xml like this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/lightblue2"
android:layout_width="match_parent"
android:id="@+id/rlTickerItem"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:id="@+id/tvCompanySymbol"
android:layout_centerVertical="true"
android:text="symbol"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:textColor="@color/darkGray"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:text="@string/ask"
android:layout_toEndOf="@+id/tvCompanySymbol"
android:id="@+id/ask"
android:layout_marginStart="4dp"
android:layout_marginEnd="1dp"
android:textColor="@color/blueButton"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/ask"
android:layout_marginStart="1dp"
android:layout_marginEnd="4dp"
android:id="@+id/tvAskAmount"
android:textColor="@color/blueButton"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:text="@string/bid"
android:layout_toEndOf="@+id/tvAskAmount"
android:id="@+id/bid"
android:layout_marginStart="4dp"
android:layout_marginEnd="1dp"
android:textColor="@color/red"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/bid"
android:layout_marginStart="1dp"
android:layout_marginEnd="4dp"
android:paddingEnd="4dp"
android:id="@+id/tvBidAmount"
android:textColor="@color/red"
android:layout_height="wrap_content" />
i need to make this recycler view marquee and ellipsize like a textview to scroll horizontally like ticker of news i put for every textview
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
and setselected(true)
from the adapter and not working
Upvotes: 4
Views: 3334
Reputation: 180
You can simply do it programmatically in onBindViewHolder of RecyclerView adapter :
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final Employees employee = mEmployees.get(position);
holder.txt_name.setText(employee.get_name());
holder.txt_name.setMarqueeRepeatLimit(2);
holder.txt_name.setHorizontallyScrolling(true);
holder.txt_name.setSingleLine(true);
holder.txt_name.setEllipsize(TextUtils.TruncateAt.MARQUEE);
holder.txt_name.setSelected(true);
}
Upvotes: 1
Reputation: 2998
here,it's work fine in recyclerview:https://blog.csdn.net/tiantaiaiqing/article/details/79200299
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:scrollHorizontally="true"
android:textSize="12dp" />
//in recyckerview textView.setSelected(true)
holder.titleTv.setSelected(true);
Upvotes: 2