我有文本视图的选框,并且可以顺利地滚动前棒棒糖版本。但不能在棒棒糖版本及以上版本中使用。请帮帮我。
以下是XML代码。
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/textView1"
android:layout_gravity="center_horizontal"
android:ellipsize="marquee"
android:singleLine="true"
android:layout_marginTop="-12dp"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="@color/white"
android:background="#00AEEF"
android:focusable="true"
android:focusableInTouchMode="true"
android:fadingEdge="horizontal"
android:freezesText="true"
/>
答案 0 :(得分:0)
scrollbars = "horizontal"
,垂直为scrollbars = "vertical"
。
尝试使用以下代码
android:maxLines = "AN_INTEGER"
android:scrollbars = "horizontal"
答案 1 :(得分:0)
创建一个MyTextView扩展TextView 然后覆盖isFocus()
public class MyTextView extends TextView {
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
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() {
//always focus
return true;
}
}
然后使用
<common.widget.MyTextView
android:id="@+id/tv_autoplay"
android:background="#CDC9C4"
android:singleLine="true"
android:ellipsize="marquee"
android:focusableInTouchMode="true"
android:focusable="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:textColor="#fff"
android:gravity="center"
android:text="marqueemarqueemarqueemarqueemarqueemarquee……………………"
android:layout_width="match_parent"
android:layout_height="30dp" />