XEditText文字輸入框的使用
阿新 • • 發佈:2018-12-18
主要功能
1,帶刪除功能的EditText;
2,顯示或者隱藏密碼;
3,可設定自動新增分隔符分割電話號碼、銀行卡號等;
4,支援禁止Emoji表情符號輸入
新增依賴
compile 'com.xw.repo:xedittext:[email protected]'
佈局檔案中
<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});