首页 > 移动平台 > 详细

android ScrollView 控制行数

时间:2017-06-19 13:55:13      阅读:178      评论:0      收藏:0      [点我收藏+]
利用ScrollView 来控制textView 显示的行数
<ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
            <span style="white-space:pre">	</span>android:maxLines="4"	//设置最大显示行数 4行
                android:scrollbars="vertical"//设置 滚动方向
                android:singleLine="false"//设置不为单行
                android:textColor="@color/white"
                android:textSize="16sp" />
        </LinearLayout>
    </ScrollView>

这个控件的目的是 最大显示四行,超过四行的有滚动条,滚动显示所有内容

还有一步,在 初始化 该textView的时候,

title = (TextView) findViewById(R.id.title);
title.setMovementMethod(ScrollingMovementMethod.getInstance());
这样就大功告成了!!



android ScrollView 控制行数

原文:http://www.cnblogs.com/jeffen/p/7048231.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!