目的是使任何文本在文本视图中自动和水平滚动。我试图找到方法,但最好的结果如下:xml
<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的任何文本水平,自动且无限次地滚动。
答案 0 :(得分:0)
使用代码
textViewSongTitleAlbumArtist.setSelected(true);
在此代码下方
textViewSongTitleAlbumArtist.setText(musicSrv.getCurrentPlayingSong().mTitle + " " + musicSrv.getCurrentPlayingSong().mArtist + " " + musicSrv.getCurrentPlayingSong().mAlbum);