android - TextView 的设置停止其他 TextView 的选取框滚动

标签 android scroll marquee

这是在别处被问到的,但解决方案对我不起作用。所以用更多的背景再次摆姿势。问题是一个 Activity 包含一个滚动的音乐标题 TextView ,它被更新的耗时计数器 TextView 中断。

我的 Activity 布局中有这两个 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"
/>

音乐标题动态设置为(在测试用例中)一长行文本。如果我从不使用以下行更新当前时间的文本,那么无论我如何与暂停和播放按钮进行交互,音乐标​​题都会愉快地永远滚动。

tvCurrentTime.setText(DataFormat.formatTime(progress));

但是如果我设置当前时间的文本,音乐标题将停止。按我的暂停按钮不知何故踢滚动回到齿轮,但按播放将导致当前时间更新并再次停止。

根据此线程中的建议,我尝试将时间文本的设置与滚动标题的重新启用结合起来,如下所示:

tvCurrentTime.setText(DataFormat.formatTime(progress));
tvTitle.setEnabled(true);

除了每次重新启动时重置滚动条之外,这对失败没有任何影响。

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

最佳答案

还有另一种方法可以在不删除所有 RelativeLayout 的情况下解决这个问题。

您可以简单地将带有 LinearLayout 的字幕 TextView 包装在 RelativeLayout 中作为容器。

关于android - TextView 的设置停止其他 TextView 的选取框滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7294779/

相关文章:

android - 使用上下文调用另一个类的方法

Android JellyBean 网络媒体问题

javascript - 根据滚动位置缩放元素并将其从图像更改为单词。

javascript - 水平和其他定向滚动

jquery - jSrcoller 总是将我的 div 固定在顶部

android - startRecording() 在三星 S7 手机上调用未初始化的 AudioRecord

Android - 分隔列表字符串

ios - 使用 UI 测试滚动单元格

silverlight - 在 Silverlight 中计算选取框类型动画的速度

javascript - 无缝 jQuery 选框?