android上垂直跑马灯,android textview 垂直滚动and水平跑马灯
垂直滾動的話就挺簡單的。當(dāng)然了不是自動的垂直滾動。如果是自動的垂直滾動的話還需要自定義。所以如果有需求需要textview 可以垂直滾動的話,那你來這里就對了。
直接貼 代碼。就是這么任性。
android:id="@+id/textview"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:maxLines="3"
android:background="#FFF"
android:textColor="#000"
android:textSize="20dp"
android:layout_margin="10dp"
android:text="23423423423423423423423423423432 2344444444444 23432423 234234
234234234
234234
234234
2342342
234234"
/> 請大家忽略 我那一串 測試的文字。 因為這樣會顯得我的x格 很低。(雖然確實很低咳咳
) 然而這樣是不行的你會發(fā)現(xiàn) 這就是一個普通的xml 的textview 啊 ?。對 你發(fā)現(xiàn)的很對。其實真相只有一個 就是這句代碼
tv.setMovementMethod(ScrollingMovementMethod.getInstance());
加上他 你就可以滾動了。不相信嘛。不相信 你可以試試
跑馬燈效果如何實現(xiàn) 貼代碼 too
android:id="@+id/textview"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:maxLines="3"
android:background="#FFF"
android:textColor="#000"
android:textSize="20dp"
android:layout_margin="10dp"
android:text="23423423423423423423423423423432 2344444444444 23432423 234234
234234234
234234
234234
2342342
234234"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
/>標(biāo)紅的是關(guān)鍵配置上就可以水平滾動了。marqueeRepeatLimit 是滾動次數(shù)。forever 是無限滾動
總結(jié)
以上是生活随笔為你收集整理的android上垂直跑马灯,android textview 垂直滚动and水平跑马灯的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android activity dia
- 下一篇: html5 indexeddb 排序,h