在Android 4.0.3中设置textview淡入淡出
我刚刚尝试在Android 4.0.3中实现TextView
的淡入淡出效果;然而,它不起作用。
fadingEdge="horizontal"
singleLine="true"
ellipsize="marquee"
此代码适用于 2.3.7 及以下版本,但不适用于 4.0.3。 我想知道为什么会这样?以及如何为TextView
制作淡入淡出效果?
我的问题与此相同:http://groups.google。 com/group/android-developers/browse_thread/thread/97131b20de8b2ebd ,但还没有答案。
I've just tried to implement the fade effect for TextView
in Android 4.0.3; however, it doesn't work.
fadingEdge="horizontal"
singleLine="true"
ellipsize="marquee"
This code works perfectly for 2.3.7 and below, but not working for 4.0.3.
I'm wondering why is that so? and how to make fade effect for TextView
?
My question is the same as this one: http://groups.google.com/group/android-developers/browse_thread/thread/97131b20de8b2ebd , but no answer yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然有点晚了,但这可能会对有同样问题的人有所帮助。
我在不同的手机上遇到过这个问题,它可能来自于:
在Android 4.0.x上,似乎TextView必须是可聚焦的,否则淡入淡出效果将不起作用。所以尝试添加这个:
android:focusable="true"
android:focusableInTouchMode="true"
如果这不起作用,您可以尝试 android:lines="1",但我认为 android:singleLine="true"(已弃用)效果更好
有时,你需要以编程方式调用 setSelected(true) textView 获得淡入淡出效果。请检查此链接:有没有办法制作椭圆形="marquee" 总是滚动?
It is a bit late, but that may help people who have the same question.
I have had this problem on different phones, and it could come from that :
on Android 4.0.x, it seems that the TextView have to be focusable, otherwise fade effect won't work. So try adding this :
android:focusable="true"
android:focusableInTouchMode="true"
if that does not work, you could try android:lines="1", but i think that android:singleLine="true", which is deprecated, works better
sometimes, you need to programmatically call setSelected(true) on the textView to get the fade effect. Please check this link : Is there a way to make ellipsize="marquee" always scroll?
从 API 级别 14 开始,
fadingEdge
已被弃用并被忽略,因此为了使淡入淡出边缘在 Android 4.0.3 上工作,您必须使用requiresFadingEdge
代替。As of API level 14
fadingEdge
is deprecated and ignored so in order to make fading edge work on Android 4.0.3 you must userequiresFadingEdge
instead.