20151128-03 TextView的滑动效果

来源:互联网 发布:linux search 编辑:程序博客网 时间:2024/05/21 11:22
1、

只要在你的布局的xml文件中设置你的TextView的属性:

android:maxLines = "AN_INTEGER"android:scrollbars = "vertical"

然后在你的代码中用:

yourTextView.setMovementMethod(new ScrollingMovementMethod())

它可以自由的滚动了。


2、加ScrollView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background"
    android:orientation="vertical" >


    <ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
    <TextView
        android:id="@+id/result"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/black"
        android:textSize="25dp" />
</ScrollView>
</LinearLayout>


0 0