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

<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

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

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



更多相关文章

  1. RelativeLayout布局属性详解
  2. android 一些常用控件属性设置
  3. Android两种 旋转Bitmap方法
  4. Android多点触摸缩放图片-android学习之旅(四)
  5. android中比较两张图片的相似度
  6. Android的Face++Demo错误1302
  7. Android(安卓)保存图片到本地
  8. Widget动态换背景图片 android
  9. 深入理解LayoutInflater

随机推荐

  1. 在Android(安卓)8.0之后版本上添加Hidl S
  2. Android基础控件(EditView、SeekBar等)的使
  3. Android(安卓)平台点对点音视频对讲
  4. Android(安卓)Studio插件之快速findViewB
  5. Android(安卓)TTS 初体验
  6. RadioGroup和RadioButton单选框
  7. Android(安卓)侧拉选择框
  8. Android[初级教程]第四篇 Spinner控件
  9. Android:TextView显示富文本信息
  10. Android(安卓)登陆页面 图片验证码