应用程序小部件上的选框 TextView
我正在开发一个 AppWidget
,我需要一个 TextView
将文本显示为选取框。我尝试使用以下代码(就像在常规 Activity
中所做的那样),但文本不滚动。
<TextView
android:layout_width="150dip"
android:layout_height="wrap_content"
android:text="@string/marquee_forever"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever" />
谁能告诉我如何解决这个问题?
I am developing an AppWidget
where I need a TextView
to display text as a marquee. I have tried using the following code (as one would do in a regular Activity
), but the text does not scroll.
<TextView
android:layout_width="150dip"
android:layout_height="wrap_content"
android:text="@string/marquee_forever"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever" />
Can anyone tell me how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在 xml 中为选取框添加以下属性:
You required to add the following properties in xml for marquee:
当Textview的内容大于宽度时,就会出现跑马灯。请确保输入占用的空间大于宽度。
The marquee will appear when the content of the Textview should be larger than width.Make sure the input occupies the greater space than width.
仅当
TextView
处于选定状态或聚焦状态时,文本才会滚动,并且如 Praveen 所示,文本比TextView
的可用宽度更宽。我还没有尝试过在应用程序小部件中获取处于选定或聚焦状态的TextView
。也许这个或这个之前的 StackOverflow 答案将为您提供一些可以尝试的东西。The text will only scroll if the
TextView
is either in the selected or focused state and, as Praveen indicates, the text is wider than the available width of theTextView
. I have not experimented with getting aTextView
in the selected or focused states in an app widget. Perhaps this or this previous StackOverflow answers will give you some things to try.