java 代码
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的滚动效果,并确保其在触摸时不改变颜色。通过使用ScrollingMovementMethod及正确设置XML属性,可以实现这一目标。
129

被折叠的 条评论
为什么被折叠?



