浏览 5545 次
锁定老帖子 主题:跑马灯效果
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-06-17
最近在網上看到有朋友貼了一段跑馬燈效果,代碼很簡單,可以有幾點關鍵的地方. <TextView android:layout_width="50px" android:layout_height="wrap_content" android:textColor="@android:color/white" android:ellipsize="marquee" android:focusable="true" android:marqueeRepeatLimit="marquee_forever" android:focusableInTouchMode="true" android:scrollHorizontally="true" android:text="这才是真正的文字跑马灯效果" > </TextView>
android:focusableInTouchMode="true" 這塊很重要 還有一個重要的地方就是: android:text="这才是真正的文字跑马灯效果",如果你的文字在手機上的長度是100px;那麼你的android:layout_width="90px" 一定要小於100px 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2011-06-22
好像没效果耶
|
|
返回顶楼 | |
发表时间:2011-06-22
当焦点不在TextView,你再看看还跑不跑!
|
|
返回顶楼 | |
发表时间:2011-06-23
这些现象确实很奇怪,有时候不一定有用的
|
|
返回顶楼 | |
发表时间:2011-06-24
android2.2一定好用 我测过的
|
|
返回顶楼 | |
发表时间:2011-06-27
kkvsyy 写道
最近在網上看到有朋友貼了一段跑馬燈效果,代碼很簡單,可以有幾點關鍵的地方. <TextView android:layout_width="50px" android:layout_height="wrap_content" android:textColor="@android:color/white" android:ellipsize="marquee" android:focusable="true" android:marqueeRepeatLimit="marquee_forever" android:focusableInTouchMode="true" android:scrollHorizontally="true" android:text="这才是真正的文字跑马灯效果" > </TextView>
android:focusableInTouchMode="true" 這塊很重要 還有一個重要的地方就是: android:text="这才是真正的文字跑马灯效果",如果你的文字在手機上的長度是100px;那麼你的android:layout_width="90px" 一定要小於100px
我试了一下 效果是有的。。。但是问题是你设置的 layout_width 宽度必须 要小于 文字内容的长度 android:text="这才是真正的文字跑马灯效果"
如果我要是设置 layout_width ="fill_parent" 岂不是非要把 text 的内容设置的很长。。。
怎么样设置的短一些 也能让他 循环滚动呢? 楼主 你给点建议不? |
|
返回顶楼 | |