0
我目前的问题如下:我有一个RecyclerView,这个RecyclerView的每个元素都有一个TextView。我希望TextView自动滚动。如果有什么到目前为止已经试过:在RecyclerView里自动滚动TextView
自定义的TextView:
public class ScrollCustomTextView extends AppCompatTextView {
public ScrollCustomTextView(Context context) {
super(context);
}
public ScrollCustomTextView(Context context, AttributeSet attrs, int defStyle) {
super(context,attrs,defStyle);
}
public ScrollCustomTextView(Context context, AttributeSet attrs) {
super(context,attrs);
}
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if (focused)
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
public void onWindowFocusChanged(boolean focused) {
if(focused)
super.onWindowFocusChanged(focused);
}
@Override
public boolean isFocused() {
return true;
}
}
和我的.xml文件看起来是这样的:
<package.ScrollCustomTextView
android:id="@+id/main_idea_name"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/darkGreen"
android:textSize="27dp"
android:layout_marginTop="10dp"
android:maxLines="1"
android:textAppearance="@android:style/TextAppearance.Medium"
/>
而在RecyclerView在为ViewHolder我设置
构造textView.setSelected(true);
但它不起作用。有没有人有解决这个问题的想法?
谢谢。