设置横向滚动首先要在layout的xml文件中先给TextView加入:
<TextView
...
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:focusable="true"
android:scrollHorizontally="true"
...
/>
然后,注意,如果textview的内容直接写到了xml中,直接上面这样设置就可以了,但是如果
textview的内容,是通过.setText设置的,还需要动态的去设置,横向滚动.
TextView layout_common_yys_textview_customerName = findViewById(R.id.layout_common_yys_textview_customerName);
layout_common_yys_textview_customerName.setText(data.customerName);
layout_common_yys_textview_customerName.setEllipsize(TextUtils.TruncateAt.MARQUEE);
layout_common_yys_