1、单独的TextView控件设置滚动条

                        android:id="@+id/content"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="file content is empty!"
                android:scrollbars="vertical"
                android:fadeScrollbars="false"
/>


在activity中为这个TextView设置:
  mFileContentView = (TextView) findViewById(R.id.content);
  mFileContentView.setMovementMethod(ScrollingMovementMethod.getInstance());


经过上面两个步骤,TextView就可以上下滚动了,如果想自定义滚动条,接着在xml里面加入属性:


android:scrollbarThumbVertical="@drawable/ic_launcher"   //滑块的图片
android:scrollbarTrackVertical="@drawable/ic_launcher"   //滑道的图片

ScrollBar由两部分组成,一个是Track(滑道),一个是Thumb(滑块)


2、也可以用ScrollView

                android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical"
            android:fadingEdge="vertical">

                        android:id="@+id/content"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="file content is empty!"/>
   



更多相关文章

  1. Android中 加载一张大图片Caused by: java.lang.OutOfMemoryErro
  2. 设置TextView文字居中
  3. Android设置背景图像重复【整理自网络】
  4. Android图片缩放效果代码
  5. Android(安卓)与H5交互心得(Base64图片)
  6. Android控件隐藏方式 .
  7. Android(安卓)代码设置Color的几种方式
  8. 修改android Launcher
  9. Android学习札记51:在TextView显示插入的图片

随机推荐

  1. Android apk重新签名
  2. android network develop(2)----network
  3. Canvas.clipPath不能用
  4. 在Android中使用NDK调用OpenGl
  5. Android 解析CSV文件,中文乱码
  6. Android 反射调用类
  7. android颜色值
  8. 【Android】向sdcard中写入文件
  9. Android传感器(六):光传感器
  10. Android 4.0 HttpURLConnection 下载失败