目标是在textview中自动水平滚动任何文本。我试图找到办法,但最好我的结果是这样的:XML水平textView自动滚动不起作用(单行弃用)
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/text_album_artist_title"
android:gravity="center"
android:text="Single-line text view that scrolls automatically if the text is too long to fit in the widget"
android:maxLines="1"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"
/>
代码
textViewSongTitleAlbumArtist = (TextView) v.findViewById(R.id.text_album_artist_title);
textViewSongTitleAlbumArtist.setSelected(true);
它的工作原理,文字自动滚动,一切正常,但是当我尝试更改textview时,它停止工作。 XML是相同的,代码是不同的:
textViewSongTitleAlbumArtist = (TextView) v.findViewById(R.id.text_album_artist_title);
textViewSongTitleAlbumArtist.setSelected(true);
textViewSongTitleAlbumArtist.setText(musicSrv.getCurrentPlayingSong().mTitle + " " +
musicSrv.getCurrentPlayingSong().mArtist + " " + musicSrv.getCurrentPlayingSong().mAlbum);
所以我要让我设置成一个TextView水平滚动,自动任何文本,次数不限。
代码
textViewSongTitleAlbumArtist.setSelected(true);
尝试使用'Android版本:内部标签滚动条= “水平”'属性。 –
尝试过,但没有成功 –