小编Gro*_*e60的帖子

TextView的设置会停止其他TextView的选框滚动

这在其他地方被问过,但解决方案对我不起作用.所以用更多的背景再次构成它.问题是活动包含滚动的音乐标题文本视图,该视图被更新的经过时间计数器文本视图中断.

我在我的活动布局中有这两个TextView小部件(尽管它们被其他布局容器包含).

<TextView android:id="@+id/v_current_time"
   android:minWidth="26dp"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_gravity="center_vertical"
   android:gravity="right|center_vertical"
   android:singleLine="true"
   android:textSize="12sp"
   android:enabled="false"
  />

<TextView android:id="@+id/v_track_title"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textSize="18sp"
   android:textStyle="normal"
   android:singleLine="true"
   android:ellipsize="marquee"
   android:marqueeRepeatLimit="marquee_forever"
   android:scrollHorizontally="true"
   android:focusable="true"
   android:focusableInTouchMode="true"
   android:enabled="true"
/>
Run Code Online (Sandbox Code Playgroud)

音乐标题被动态设置为(在测试用例中)一长行文本.如果我从未使用以下行更新当前时间的文本,则无论我如何与暂停和播放按钮进行交互,音乐标​​题都将很乐意滚动.

tvCurrentTime.setText(DataFormat.formatTime(progress));
Run Code Online (Sandbox Code Playgroud)

但如果我确定当前时间的文本,音乐标题将停止.按下我的暂停按钮以某种方式将滚动回到齿轮,但按下播放将导致当前时间更新并再次停止.

根据这个帖子中的建议,我试图将时间文本的设置与重新启用滚动标题结合起来,如下所示:

tvCurrentTime.setText(DataFormat.formatTime(progress));
tvTitle.setEnabled(true);
Run Code Online (Sandbox Code Playgroud)

除了每次重新启动时重置滚动条以外,这对失败没有影响.

是否有一些我遗漏的细节,或者有什么可能出错的其他想法?非常感谢!

android scroll marquee

8
推荐指数
2
解决办法
5184
查看次数

标签 统计

android ×1

marquee ×1

scroll ×1