android TextView不用ScrollViewe也可以滾動的方法
更新時間:2013年11月18日 16:51:31 作者:
這篇文章主要介紹了android TextView不用ScrollViewe也可以滾動的方法,很簡單實用的代碼,大家參考使用吧
代碼
復制代碼 代碼如下:
TextView textview = (TextView) findViewById(R.id.text);
/** *
* 只有調(diào)用了該方法,TextView才能不依賴于ScrollView而實現(xiàn)滾動的效果。
* 要在XML中設置TextView的textcolor,否則,當TextView被觸摸時,會灰掉。
*/
textview.setMovementMethod(ScrollingMovementMethod.getInstance());
xml文件
復制代碼 代碼如下:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:scrollbars="vertical"
android:maxLines="12"
android:textColor="@color/white"
android:text="@string/str"
android:id="@+id/text"
></TextView>
您可能感興趣的文章:
- android TextView設置中文字體加粗實現(xiàn)方法
- Android TextView設置背景色與邊框的方法詳解
- Android編程開發(fā)之TextView文字顯示和修改方法(附TextView屬性介紹)
- Android TextView字體顏色設置方法小結
- android實現(xiàn)上下滾動的TextView
- android TextView多行文本(超過3行)使用ellipsize屬性無效問題的解決方法
- Android設置TextView顯示指定個數(shù)字符,超過部分顯示...(省略號)的方法
- Android中TextView顯示圓圈背景或設置圓角的方法
- Android中TextView實現(xiàn)分段顯示不同顏色的字符串
- Android?妙用TextView實現(xiàn)左邊文字,右邊圖片
相關文章
Android編程實現(xiàn)在自定義對話框中獲取EditText中數(shù)據(jù)的方法
這篇文章主要介紹了Android編程實現(xiàn)在自定義對話框中獲取EditText中數(shù)據(jù)的方法,結合實例形式分析了Android對話框數(shù)據(jù)傳遞相關操作技巧,需要的朋友可以參考下2018-01-01Android 在 res/layout 文件夾 下創(chuàng)建一個 子文件夾實例
這篇文章主要介紹了Android 在 res/layout 文件夾 下創(chuàng)建一個 子文件夾實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03