具体步骤:

第一步: xml 文件

<TextView android:id="@+id/txt"        android:layout_width="fill_parent"         android:layout_height="fill_parent"                android:scrollbars="vertical"        android:singleLine="false"          android:maxLines="10"         android:textSize="18sp"        android:textColor="#ff0000"        android:text="xxxxxx"</TextView>

第二步: java 文件

TextView textView = (TextView)findViewById(R.id.txt); textView.setMovementMethod(ScrollingMovementMethod.getInstance());

注意:

1. 只有调用了该方法,TextView才能不依赖于ScrollView而实现滚动的效果。
2. 要在XML中设置TextView的 textcolor,否则,当TextView被触摸时,会灰掉。

更多相关文章

  1. AndroidManifest.xml文件详解(data)
  2. android 根据string 获取资源文件的id
  3. Android 实例子源代码文件下载地址380个合集
  4. android 布局文件中xmlns:android="http://schemas.android.com/
  5. Android——导入已存在的android工程时出现红叉错误“AndroidMan
  6. android中xml文件的使用详解
  7. [摘]android 入门xml布局文件
  8. Android 选择文件并返回路径

随机推荐

  1. Android(安卓)之 使用MediaPlayer播放音
  2. Google Android(安卓)应用程序结构
  3. OpenGL ES for Android(安卓)环境搭建
  4. Android自动化测试工具——Monkey
  5. Android中外部程序调用方法总结
  6. Android之Bluetooth
  7. 远程调测:Chrome on Android之三 调测WebV
  8. Android应用程序启动过程源代码分析
  9. 【笔记】android sdk集成的eclipse中导入
  10. 系出名门 Android(安卓)系列文章索引