ConfirmationCodeView is a Android custom view for inputing confirmation code. 一个简易的短信验证码控件
dependencies{
compile 'com.wray:ConfirmationCodeView:1.0.0@aar'
}
<dependency>
<groupId>com.wray</groupId>
<artifactId>ConfirmationCodeView</artifactId>
<version>1.0.0</version>
<type>pom</type>
</dependency>
attribute | instruction | value |
---|---|---|
ccvCount | The confirmation code length. | integer |
ccvLineWidth | The width of the code border or underline. | dimension |
ccvSize | the size of each code box. | dimension |
ccvPadding | the padding of each code box. | dimension |
ccvText | the content string.(The part beyond the length will be truncated) | string |
ccvContentType | The content input type. - mixture : both letter and digit. - letter : accept letter only. - digit : accept digit only |
string |
ccvDirection | The input direction. - ltr : from left to right. - rtl : from right to left |
string |
ccvBorderShape | The shape of the border. - line : use underline only. - square : use a square border. - squareLine : use underline with square content area. - rectangle : use a rectangle border. - circle : use a circle border. |
string |
ccvBorderColor | The border color. | color | reference |
ccvBorderSelectColor | The border selection color. | color | reference |
ccvBorderRadius | The border corner radius. | dimension |
ccvPasswordMode | Indicate the password mode. | boolean |
ccvTextColor | The text color. | color | reference |
ccvTextSelectColor | The text selection color. | color | reference |
ccvPasswordColor | The password color. | color | reference |
ccvPasswordSelectColor | The password selection color. | color | reference |
ccvContentColor | The content background color. | color | reference |
ccvContentSelectColor | The content selection background color. | color | reference |
Simple Use:
<com.wray.ccview.ConfirmationCodeView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
More Attibutes:
<com.wray.ccview.ConfirmationCodeView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:ccvBorderShape="square"
app:ccvCount="4"
app:ccvContentType="letter"
app:ccvDirection="rtl"
app:ccvSize="45dp" />
ConfirmationCodeView ccv;
......
ccv.setBorderColor(color);
ccv.setBorderSelectColor(color);
ccv.setContentColor(android.R.color.white);
ccv.setTextColor(color);
ccv.setTextSelectColor(android.R.color.white);
ccv.setContentSelectColor(color);
ccv.setPasswordColor(color);
ccv.setPasswordSelectColor(android.R.color.white);
ccv.setOnInputCompletionListener(new ConfirmationCodeView.OnInputCompletionListener() {
@Override
public void onCompletion(ConfirmationCodeView ccv, String content) {
Log.d("", "Your Input Code : " + content);
}
});
The MIT License (MIT)
Copyright (c) 2018 Ray
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.