我有以下文本视图:
<TextView
android:id="@+id/detailsText"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Long text Long text Long text Long text Long text Long text "
android:textAppearance="?android:attr/textAppearanceLarge"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true" />
文本会自动从右向左滚动(这是我正在寻找的),但在配置更改后,文本会从头开始滚动。我试图android:configChanges="orientation|keyboardHidden|screenSize"
在我的代码中使用和处理配置更改,但这不起作用。我还发现不再建议使用这种技术,并尝试使用 Fragments 代替,但没有任何效果。我还尝试找出 scrollHorizontally 正在修改哪个值以使其滚动,因此我可以尝试保存和恢复它,但我从来没有找到它(例如,textview.getScrollX() 始终保持在 0)。
我还注意到,当我使用这些textview.setVisibility(View.GONE); and textview.setVisibility(View.VISIBLE);
方法时,也会发生这种“滚动重启”。
谢谢您的帮助。