XEditText文本输入框的使用

版权声明:转载必须注明本文转自郭子轩的博客 https://blog.csdn.net/gpf1320253667/article/details/85062988

主要功能

1,带删除功能的EditText;
2,显示或者隐藏密码;
3,可设置自动添加分隔符分割电话号码、银行卡号等;
4,支持禁止Emoji表情符号输入

添加依赖

compile 'com.xw.repo:xedittext:2.1.0@aar'

布局文件中

<com.xw.repo.XEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="default, just likes EditText"
      app:x_disableClear="true"/>

 <com.xw.repo.XEditText
            android:id="@+id/clear_marker_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="default password input"
            android:inputType="textPassword"
            android:maxLength="30"/>

  <com.xw.repo.XEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="default password input"
      android:inputType="textPassword"/>

  <com.xw.repo.XEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="pwd input, custom drawables"
      android:inputType="textPassword" <!-- don't set gravity to center, center_horizontal, right or end, otherwise the ClearDrawable will not appear. -->
      app:x_clearDrawable="@mipmap/ic_clear" <!--support vector drawable-->
      app:x_hidePwdDrawable="@mipmap/ic_hide" <!--support vector drawable-->
      app:x_showPwdDrawable="@mipmap/ic_show"/> <!--support vector drawable-->

  <com.xw.repo.XEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:hint="the pattern to separate the content"
      app:x_pattern="3,4,4"
      app:x_separator=" "/>
      
<com.xw.repo.XEditText
            android:id="@+id/custom_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="customize separating pattern"
            android:inputType="phone"
            app:x_separator="-"/>
        <!-- if you want to separate, do not set maxLength attr -->

<com.xw.repo.XEditText
            android:id="@+id/enable_emoji_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:hint="enable emoji inputting"
            app:x_disableEmoji="false"/>

        <com.xw.repo.XEditText
            android:id="@+id/disable_emoji_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="disable emoji inputting"
            app:x_disableEmoji="true"/>

代码中设置分隔:

showXEdit.setSeparator(" ");
showXEdit.setPattern(new int[]{3, 4, 4});

猜你喜欢

转载自blog.csdn.net/gpf1320253667/article/details/85062988