翻翻git之---逻辑清晰,简单好用的App内部锁控件 PinLockView
来源:互联网 发布:中企网络通信 项目经理 编辑:程序博客网 时间:2024/05/13 00:39
转载请注明出处王亟亟的大牛之路
先安利,收纳库:https://github.com/ddwhan0123/Useful-Open-Source-Android 每天都在更!!!
上一篇关于学习和职场的一些看法,评论不错阅读量不佳(估计是没分享到主页的缘故吧,这里再安利下):http://blog.csdn.net/ddwhan0123/article/details/51646255
废话不多说,开始这一篇的内容
之前也有看到过一些类似的应用锁实现,今天看到个比较好看+好用的就推荐给大家
先看下运行效果:
How to use?
Gradle
dependencies { // other dependencies here compile 'com.andrognito.pinlockview:pinlockview:1.0.0'}
Maven
<dependency> <groupId>com.andrognito.pinlockview</groupId> <artifactId>pinlockview</artifactId> <version>1.0.0</version> <type>pom</type></dependency>
Eclipse的小伙们再见!!!
来看下例子里怎么用的
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto" android:background="@color/mine_shaft" tools:context="com.andrognito.pinlockviewapp.SampleActivity"> <ImageView android:id="@+id/profile_image" android:layout_width="84dp" android:layout_height="84dp" android:layout_centerHorizontal="true" android:layout_marginTop="124dp" android:src="@drawable/img_no_avatar" /> <TextView android:id="@+id/profile_name" android:layout_width="256dp" android:layout_height="wrap_content" android:layout_below="@+id/profile_image" android:layout_centerHorizontal="true" android:layout_marginTop="36dp" android:fontFamily="sans-serif-thin" android:gravity="center" android:maxLines="1" android:text="Welcome" android:textColor="@color/white" android:textSize="34sp" /> <com.andrognito.pinlockview.IndicatorDots android:id="@+id/indicator_dots" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/profile_name" android:layout_centerHorizontal="true" android:layout_marginTop="36dp" /> <com.andrognito.pinlockview.PinLockView android:id="@+id/pin_lock_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/indicator_dots" app:keypadButtonSize="72dp" app:keypadTextSize="18dp" app:keypadShowDeleteButton="false" app:keypadTextColor="@color/white" android:layout_centerHorizontal="true" android:layout_marginTop="16dp" /></RelativeLayout>
主要是密码锁的 IndicatorDots 和 “按键实现的” PinLockView 就和普通控件一样用就行,最多加点自定义标签,标签在后面会解释
看下Activity里怎么用的(解释在注视里)
public class SampleActivity extends AppCompatActivity { public static final String TAG = "PinLockView"; private PinLockView mPinLockView; private IndicatorDots mIndicatorDots; //监听密码输入情况 private PinLockListener mPinLockListener = new PinLockListener() { //输入长度达到length后触发 @Override public void onComplete(String pin) { Log.d(TAG, "Pin complete: " + pin); Toast.makeText(SampleActivity.this, "密码输完了是 " + pin, Toast.LENGTH_SHORT).show(); } //为空时触发 @Override public void onEmpty() { Log.d(TAG, "Pin empty"); } //输入内容变化时触发 @Override public void onPinChange(int pinLength, String intermediatePin) { Log.d(TAG, "Pin changed, new length " + pinLength + " with intermediate pin " + intermediatePin); } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_sample); mPinLockView = (PinLockView) findViewById(R.id.pin_lock_view); mIndicatorDots = (IndicatorDots) findViewById(R.id.indicator_dots); //2个控件产生关联 mPinLockView.attachIndicatorDots(mIndicatorDots); //添加监听事件 mPinLockView.setPinLockListener(mPinLockListener); //设置密码总长度 mPinLockView.setPinLength(4);//设置按钮颜色 mPinLockView.setTextColor(getResources().getColor(R.color.white)); }}
列出其他的一些自定义标签
app:pinLength="6" // 改pin的长度 app:keypadTextColor="#E6E6E6" // 设置键盘字体颜色 app:keypadTextSize="16dp" // 设置键盘字体大小 app:keypadButtonSize="72dp" // 设置按钮大小 app:keypadVerticalSpacing="24dp" // 改变键盘按钮之间的垂直间隔 app:keypadHorizontalSpacing="36dp" // 改变键盘按钮之间的水平间距 app:keypadButtonBackgroundDrawable="@drawable/bg" // 设置按钮背景图片 app:keypadDeleteButtonDrawable="@drawable/ic_back" // 设置删除按钮图片 app:keypadDeleteButtonSize="16dp" // 设置删除按钮图标大小 app:keypadShowDeleteButton="false" // 设置是否显示删除按钮,默认不显示 app:keypadDeleteButtonPressedColor="#C8C8C8" // 更改删除按钮的按/焦点状态颜色 app:dotEmptyBackground="@drawable/empty" // 自定义点的空状态 app:dotFilledBackground"@drawable/filled" // 自定义点的填充状态 app:dotDiameter="12dp" // 改变点的直径 app:dotSpacing="16dp" // 改变单个点之间的间距
源码地址:https://github.com/aritraroy/PinLockView/archive/master.zip
该库已收入:https://github.com/ddwhan0123/Useful-Open-Source-Android
欢迎扫码+我,有问题/有私活可以M我(广告/骚扰 勿扰)
谢谢观众老爷观看
3 0
- 翻翻git之---逻辑清晰,简单好用的App内部锁控件 PinLockView
- 翻翻git之---SharedPreferences好用的封装库 PreferencesManager
- 翻翻git之---实用的进度类自定义控件LoadingDrawable
- 翻翻git之---一个简单的标签控件 LabelView (随手发了两张小宝宝的玩耍照)
- 翻翻git之---简单易用的状态栏工具库 StatusBarUtil
- 翻翻git之---低内存损耗,简单易用的汉字->拼音转换库 TinyPinyin
- 翻翻git之---实用工具类Lazy(绝对的好东西,走过路过别错过)
- 翻翻git之---实用工具类Lazy(绝对的好东西,走过路过别错过)
- 翻翻git之---基于universalimageloader实现的图片加载控件BlurImageView
- 翻翻git之---实现Material Bottom Navigation的自定义控件 LuseenBottomNavigation
- 翻翻git之---实现QQ空间点赞部分实现的自定义控件 EasyLikeArea
- 翻翻git之---足以取代底部PoPupWindows的强大控件 BottomSheet
- 翻翻git之---简单的配置达到产品在应用市场的评价跳转功能
- 逻辑清晰、简单的二分查找
- 翻翻git之---溜的飞起的加载效果AVLoadingIndicatorView
- 翻翻git之---好看的卡片切换库 Swipecards
- 翻翻git之---炫酷的自定义翻滚View TagCloudView
- 翻翻git之---一个丰富的通知工具类 NotifyUtil
- Android 获取本地视频缩略图和某一帧的预览图
- HashMap和Hashtable的区别
- JQuery基础
- 派生类成员的访问
- Mysql数据库insert into select 单表插入常量
- 翻翻git之---逻辑清晰,简单好用的App内部锁控件 PinLockView
- 强悍的 Ubuntu —— cairo-dock
- Linux(1)Linux常用命令_搜索命令_grep命令
- 【Swift】获取设备信息
- Leetcode No.104 Maximum Depth of Binary Tree 遍历二叉树的深度
- Mac OS X 配置环境变量
- thinkphp连接多数据库
- Linux TCP队列相关参数的总结
- Android layer-list与shape的使用