PIN 码专用输入控件,支持任意长度和输入任意数据
- allprojects {
- repositories {...maven {
- url 'https://jitpack.io'
- }
- }
- }
- dependencies {
- compile 'com.github.nanchen2251:PinView:1.0.1'
- }
- mPinView.setCanInput(true); // 设置是否可输入 默认true
- mPinView.setHint(""); // 设置EditText的Hint
- mPinView.setInputType(PinView.InputType.NUMBER); // 设置输入的格式
- mPinView.setPassword(true); // 设置是否以明文显示
- mPinView.setPinHeight(60); // 设置每一个EditText的高度
- mPinView.setPinWidth(60); // 设置每一个EditText的宽度
- mPinView.setPinLength(4); // 设置可输入的 PIN 码长度,默认4
- mPinView.clearValue(); // 清除输入的数据
- mPinView.setValue("1234"); // 设置输入值
- mPinView.setPinViewEventListener(this); // 设置输入完毕的监听事件
- <com.nanchen.pinview.PinView
- android:id="@+id/pinView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:layout_marginLeft="20dp"
- app:cursorVisible="false"
- app:forceKeyboard="false"
- app:hint=""
- app:inputType="number"
- app:password="true"
- app:pinBackground="@drawable/example_drawable_with_grey_disabled"
- app:pinHeight="30dp"
- app:pinLength="4"
- app:pinWidth="30dp"
- app:splitWidth="20dp"/>
- Copyright 2018 nanchen(刘世麟)
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
来源: https://juejin.im/entry/5a4db6c7f265da432d288454