# pinView **Repository Path**: JndroidCode/pinView ## Basic Information - **Project Name**: pinView - **Description**: pin输入框、密码输入框 - **Primary Language**: Android - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2018-06-05 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PinView Provides a widget for enter PIN/OTP/password etc on Android 4.1+ (API 16).

## Dependency ``` Groovy repositories { maven { jcenter() } } dependencies { compile 'com.scorpio:pinview:0.0.1' } ``` ## Usage PinView inherits from EditText, which means you can use all the APIs from EditText. ### Step 1: Add PinView in your layout. #### XML ``` xml ``` #### Java ``` Java PinView pinView = (PinView) findViewById(R.id.secondPinView); pinView.setTextColor( ResourcesCompat.getColor(getResources(), R.color.colorAccent, getTheme())); pinView.setTextColor( ResourcesCompat.getColorStateList(getResources(), R.color.text_colors, getTheme())); pinView.setLineColor( ResourcesCompat.getColor(getResources(), R.color.colorPrimary, getTheme())); pinView.setLineColor( ResourcesCompat.getColorStateList(getResources(), R.color.line_colors, getTheme())); pinView.setItemCount(4); pinView.setItemHeight(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_size)); pinView.setItemWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_size)); pinView.setItemRadius(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_radius)); pinView.setItemSpacing(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_spacing)); pinView.setLineWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_line_width)); pinView.setAnimationEnable(true);// start animation when adding text pinView.setCursorVisible(false); pinView.setCursorColor( ResourcesCompat.getColor(getResources(), R.color.line_selected, getTheme())); pinView.setCursorWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_cursor_width)); pinView.addTextChangedListener(new TextWatcher() {...}); ``` ### Step 2: Specifies `pinViewStyle` in your theme, ``` xml ``` or use the `PinWidget.PinView` style. ``` xml ``` ### Step 3 (Optional): To highlight current item, add `android:state_selected="true"` to `app:lineColor` ``` xml ``` or add `android:cursorVisible="true"`. ## Attributes * **itemCount**, the length of your pin code. * **itemWidth**, the width of each item. * **itemHeight**, the height of each item. * **itemSpacing**, the spacing between two items. * **lineWidth**, the line (border) width. * **lineColor**, the line (border) colors. * **viewType**, the view type of PinView, currently this will be one of `rectangle` or `line`. * **cursorColor**, the cursor color. * **cursorWidth**, the width of cursor. ## Thanks * Inspired by [PasswordInput](https://github.com/EthanCo/PasswordInput) in [EthanCo](https://github.com/EthanCo) ## License Copyright 2017 Chaos Leong 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.