Android TextView 手动上下滑动
生活随笔
收集整理的這篇文章主要介紹了
Android TextView 手动上下滑动
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
有時(shí)候項(xiàng)目需求,TextView只顯示若干行,其他部分隱藏,需要滑動(dòng)才會(huì)顯示,一般默認(rèn)都是自動(dòng)填充全部顯示,或者手動(dòng)設(shè)置高度,那樣文字就顯示不全,這時(shí)候可以使用下面的解決方案,代碼設(shè)置顯示的行數(shù),然后上下滑動(dòng)的時(shí)候顯示其他文字。
?
布局代碼:
<TextView android:id="@+id/tv"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="jjghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhtttttttttttttttttt"android:maxLines = "1"android:scrollbars = "vertical"android:layout_below="@id/wvContent"/>
注意:
?
?
android:maxLines,需要顯示的行 android:scrollbars = "vertical" 垂直滑動(dòng),毫無疑問可以設(shè)置水平然后代碼再加一句:
TextView tv = (TextView)findViewById(R.id.tv); tv.setMovementMethod(new ScrollingMovementMethod());
?
轉(zhuǎn)載于:https://www.cnblogs.com/spring87/p/5094991.html
總結(jié)
以上是生活随笔為你收集整理的Android TextView 手动上下滑动的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: URLCache探索
- 下一篇: 制作bat脚本,抓取Android设备l