zoukankan      html  css  js  c++  java
  • EditText 几种显示方式,固定行数,自适应行数

    1.显示7行,超过7行自动向下补充行数

      <EditText
        android:id="@+id/edt_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:gravity="left|top"
        android:hint="请输入作业内容"
        android:inputType="textMultiLine"  <!--设置可以多行-->
        android:maxLength="800"    <!-- 限制最大可输入字符数 -->
        android:minLines="7"          <!-- 初始化时显示的是7行 -->
        android:padding="10dp"     
        android:paddingLeft="10dp"
        android:textSize="14sp" />

     2.自动滚动条,并显示最新内容

      <EditText

        android:id="@+id/edt_content"
        android:layout_width="fill_parent"
        android:layout_height="260px"
        android:textColor="#000000"
        android:padding="5px"
        android:scrollbars="vertical"  <!--垂直滚动条-->
        android:singleLine="false"    <!--多行-->
        android:maxLines="14"       <!--最多显示14行-->
        android:focusable="false"
        android:clickable="true"
        android:background="#ff87CEEB"
       />

      要在Java代码中设置滚动的方法( EditText mEdtContent ):

      mEdtContent.setMovementMethod(ScrollingMovementMethod.getInstance());

      下面是设置显示最新的内容:

      mEdtContent.setSelection(chatsView.getText().length(), chatsView.getText().length());

  • 相关阅读:
    树上路径
    [HNOI2017]礼物
    Spoj 8372 Triple Sums
    [Swerc2014 C]Golf Bot
    【bzoj2194】快速傅立叶之二 FFT
    Linux下perl模块安装
    angularjs form表单验证
    Angularjs兼容IE
    input file限制上传文件类型
    angularjs判断页面数据是否渲染完成
  • 原文地址:https://www.cnblogs.com/woaixingxing/p/5633252.html
Copyright © 2011-2022 走看看