android TextView不用ScrollViewe也可以滚动的方法
2014-09-25 15:02
225 查看
这篇文章主要介绍了android TextView不用ScrollViewe也可以滚动的方法,很简单实用的代码,大家参考使用吧。
TextView textview = (TextView) findViewById(R.id.text);
/** *
* 只有调用了该方法,TextView才能不依赖于ScrollView而实现滚动的效果。
* 要在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>
TextView textview = (TextView) findViewById(R.id.text);
/** *
* 只有调用了该方法,TextView才能不依赖于ScrollView而实现滚动的效果。
* 要在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不用ScrollViewe也可以滚动的方法
- android TextView不用ScrollViewe也可以滚动的方法
- android TextView不用ScrollViewe也可以滚动的方法
- android TextView不用ScrollViewe也可以滚动的方法
- TextView不用ScrollViewe也可以滚动的方法
- iOS-自定义TextView的方法,可以设置占位文字(placeholder)又可滚动
- Android实现在TextView文字过长时省略部分或滚动显示的方法
- Android开发中TextView文本过长滚动显示实现方法分析
- Android文字自动横向滚动的TextView(文字长度不够也可以)
- TextView 不用 ScrollViewe 也可以滚动
- Android TextView多行文本滚动实现与ScrollView的滚动条为隐藏的方法
- 让android的TextView可以滚动
- Android TextView实现垂直滚动效果的方法
- Android可以纵向滚动的textView
- Android textview 不使用ScrollView也可滚动的方法
- android TextView不用获得焦点实现跑马灯效果 两种方法
- Android 使TextView文本可以水平和垂直滚动
- 关于Android使TextView可以滚动的设置
- Android TextView实现滚动效果
- android中TextView属性方法总结