zoukankan      html  css  js  c++  java
  • Android TextView 手动上下滑动

    有时候项目需求,TextView只显示若干行,其他部分隐藏,需要滑动才会显示,一般默认都是自动填充全部显示,或者手动设置高度,那样文字就显示不全,这时候可以使用下面的解决方案,代码设置显示的行数,然后上下滑动的时候显示其他文字。

    布局代码:

      <TextView 
            android:id="@+id/tv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="jjghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhtttttttttttttttttt"
            android:maxLines = "1"
            android:scrollbars = "vertical"
            android:layout_below="@id/wvContent"
            />
    

      

      

    注意:

    android:maxLines,需要显示的行
    android:scrollbars = "vertical" 垂直滑动,毫无疑问可以设置水平

    然后代码再加一句:






    TextView tv = (TextView)findViewById(R.id.tv);
    tv.setMovementMethod(new ScrollingMovementMethod());
    

      



  • 相关阅读:
    软件工程第四次作业
    软件工程第三次作业
    图片
    软件工程第二次作业
    软件工程第一次作业
    我的大学生活-3-35-任延勇
    我的未来只有我知道
    cpu占用率高排查知识点
    LeetCode字符串题目
    hashmap
  • 原文地址:https://www.cnblogs.com/spring87/p/5094991.html
Copyright © 2011-2022 走看看