可否增加三星滑动屏幕解锁取消的滑动方式的设置

安卓手机屏幕锁设置方法(九个点图案)
作者:佚名
字体:[ ] 来源:互联网 时间:06-28 00:37:38
最近朋友购买了android手机,看到别人以前多是用九个点的图案的解锁,默认是滑动即可,但为了防止别人随便动我们的手机,最好是用密码或图案锁,一般情况下android是自带的,所有android都是可以支持的
这里以三星S5368手机屏幕锁为例
  随着三星S5368手机系统功能愈来愈完善,性能愈来愈强劲,越来越多的三星S5368用户们都喜欢把一些重要的信息甚至隐私放在三星S5368手机里面,但是这就有可能会让别人看到,这样一来你的三星S5368里面的信息就会不安全了,怎样可以让三星S5368手机里面的信息和隐私不让外人看到呢?今天巴士三星的小编告诉各位三星S5368用户们一个方法。
  三星S5368手机屏幕锁步骤:
  1.按住三星S5368手机的Menu,进入下面的界面:
  2.根据上面的图片来设置三星S5368,进入&安全&菜单,设置屏幕锁定和SIm卡锁定。
  3.三星S5368手机在上图所示的图片中设置解锁图案,然后会进行下一个步骤。
  4.三星S5368设置好解锁图案后,需要再进行绘制解锁图案,你需要记住自己所绘制的图案,因为需要确认一次才会绘制成功的,如上图所示。
  5.三星S5368手机设置绘制好解锁图案后会返回到上面的那个界面,在需要图案的勾上选择就可以的了。
  6.最后三星S5368手机锁屏后,就会出现上面的界面,而且只有绘制正确的图案后才可以进入三星S5368手机里面,或者只有紧急电话可以使用,其余的必须要正确绘制图案才可以进入的。
  以上就是八十三星的小编为各位三星S5368用户们提供的关于三星S5368手机屏幕锁的方法,其实是很简单的,大家都可以试试的,这样你的三星S5368手机就更加安全了,也不会担心三星S5368手机里面的信息泄露出去了。Android手机如何设置屏幕锁 加强安全&屏幕解锁&这个功能相信大家都觉得蛮实用的,但是大家肯定也都会发现每次解锁的时候、解锁方式经常都会被周围的人看见。 下面就跟大家介绍下怎么让你的屏幕锁更安全。首先在设置里 找到安全性和位置,把&使用可见图案&这项取消这时候就不用怕别人偷窥到你的&屏幕锁&了 如何设置安全锁:进入安全性后 找到设置解锁图案,阅读后点击下一步 ,接下来的工作就是绘制解锁图案了,绘制完后 松开手指 点击下一步,重新绘制图案 确定一下,然后再次确认,返回到上一级菜单,把使用可见图案的勾打掉就
大家感兴趣的内容
12345678910
最近更新的内容iOS10怎么解锁屏幕 4种iOS10屏幕解锁方法 - iPhone使用技巧 - 电脑百事网
手机扫描二维码
iOS10怎么解锁屏幕 4种iOS10屏幕解锁方法
来源:电脑百事网原创
编辑:admin
全新的iOS 10解锁与iOS 9滑动解锁有所不同,它默认不再采用滑动解锁方式,而是按Home键实现解锁,下面本文详细分享多种iOS10解锁方法,教大iOS10怎么轻松解锁屏幕。方法一:Home键解锁iOS 10最常用的解锁方式就是按Home键解锁了,只要开启了指纹识别功能,就可以通过指纹手指,轻按Home键,轻松解锁。在亮屏模式下,请按主屏幕按钮(Home键)完成解锁屏幕操作很简单,在熄屏下可以按下电源键亮屏,然后按下Home键即可解锁屏幕。另外,也可以通过双击Home键解锁屏幕。方法二:触摸Home键解锁屏幕其实iOS 10解锁屏幕非常方便,只要在亮屏下,将指纹手指放置在Home键上大约5秒,就可以快速指纹解锁,完全不用按Home键也行(熄屏下,可以先按下电源键或者Home键唤醒屏幕)。方法三:使用密码解锁如果没有指纹,需要使用密码解锁,也很简单,连续按2次Home键,就会弹出输入密码界面,输入密码就可以解锁了。
方法四:设置抬手自动解锁iOS 10加入抬腕唤醒屏幕功能,只需要进入设置-&屏幕与亮度,然后开启抬腕唤醒功能。之后只要拿起手机,屏幕会自动亮起,受放在Home键(无需按),大约3s后就会自动指纹解锁了。以上就是iOS10解锁屏幕教程,分享了4种方法,掌握这些你就可以轻松解锁设备了。虽然iOS 10没有了滑动解锁,但借助Home键,解锁其实更为方便快捷。苹果6plus破解id密码_苹果6plus破解id密码_百度 _ 知道
当前位置: >> >>
苹果6plus破解id密码
中央政府门户网站   
04:46:45   来源:旅游局网站
【E-mail推荐
苹果6plus破解id密码 苹果6plus破解id密码【苹果ID解锁-QQ:】开锁率高达100%,解锁QQ:,解开1小时内结清尾款。放心选择,无需拆机,无需邮寄,报机器信息就可以。零风险。
  原标题:《火星情报局》获G客盛典年度最佳综艺大奖
  1月12日,由咪咕视讯、共青团中央学校部、共青团中央网络影视中心、中国网络电视台主办,优酷土豆、中青盛世、央视易橙、央广视讯、华谊创星协办的第七届“G客盛典暨G客网络电影年度盛典”在上海举行。在这场中国原创视频界一年一度的盛事上,由优酷和银河酷娱出品、快乐全球联合出品的《火星情报局》荣获年度最佳综艺大奖。作为原创网综的佼佼者,《火星情报局》的高品质再一次得到了业界肯定。
  《火星情报局》原创品质获赞 力挫群雄摘年度最佳综艺大奖
  为全力支持中国文化内容创意产业,同时提升互联网原创视频的产业规模,咪咕视讯(原“中国移动视频基地”)从2010年起持续举办“G客原创视频大赛”及“G客盛典”,至今已成功举办了六届。
  在1月12日上海举办的第七届“G客盛典暨G客网络电影年度盛典”上,《火星情报局》力挫群雄,摘得年度最佳综艺大奖。《火星情报局》灵感来源于英国议会的原创提案模式,新颖的“我发现”议题话术,配合人人平等的提案模式,一度成为网友热议的焦点。在以原创精神为主旨的G客盛典上获得肯定,《火星情报局》制作团队一直坚持的创新精神可谓功不可没。《火星情报局》来源于生活的提案,经过火星特工们爆笑的演绎、让远程特工们在收获满满欢笑的同时,也能有所触动和感悟。银河酷娱联合创始人、《火星情报局》总导演兼总制片人胡明认为,是所有特工的努力才让这一不存在的“火星情报局”能够如此形象和真实。
  除此,《火星情报局》中的高级特工们,以及节目年轻化的思维模式,使之牢牢抓住了年轻人的心。有品质有共鸣的提案内容、轻松爆笑的议会讨论模式,加上火星特工们的生动演绎,这些元素加在一起迸发出来的化学效应,让《火星情报局》成为当下年轻人最爱看的网络综艺节目。
  应采儿刘维唱rap 全场high翻天脑洞大到没朋友
  在当晚的盛典中,大优酷综娱资讯中心高级总监、《火星情报局》总监制宋秉华和银河酷娱联合创始人、《火星情报局》总导演兼总制片人胡明共同领取奖杯。为表达对奖项的重视,《火星情报局》还派出了副局长应采儿和高级特工刘维到场,一同接受荣誉。
  应采儿和刘维到场自然不会只是领奖,表演是少不了的。随着熟悉的《火星情报局》片头乐的响起,两人拿起节目中的提案本,开启搞怪演唱模式。他们把火星会议中好玩的桥段巧妙地编成歌词,用说唱的形式表达出来,不断引发现场共鸣。尤其是刘维唱的“火星播放破十亿,火星招商全网第一”,霸气展示“火星”成绩引来全场尖叫。
  应采儿和刘维带来的这段“火星”专属rap轻松点燃现场的气氛,面对观众的欢呼,主持人也不淡定了,感慨道,“《火星情报局》就是不一样,就是这么热闹啊!”
  《火星情报局》成超级网综范本 开发“火星”IP酝酿系列大动作
  《火星情报局》第一季斩获9亿的高播放量,业内人士估计,《火星情报局2》收官时的播放总量则有望突破13亿。在播放量捷报频传的同时,《火星情报局》在微博、豆瓣等新媒体社区的讨论量也一直居高不下,节目美誉度也节节攀升。正如胡明在发表获奖感言时所说,“《火星情报局》有望成为一代又一代年轻人共同的情结和回忆”。
  作为优酷联手银河酷娱打造的首档网综,《火星情报局》无疑是成功的。能在竞争激烈的网综市场取得如此成绩离不开其幕后公司超高的制作品质。“《火星情报局》的所有创作人员都是有着十多年电视工作经验的佼佼者。”胡明在盛典上说。而此次在G客盛典上获得份量最重的年度最佳综艺大奖,也从专业层面上印证了《火星情报局》的超高品质,以及在原创视频领域的价值。
  据了解,在成功打造网综《火星情报局》之后,优酷携手银河酷娱正酝酿通过一系列大动作,把“火星”这一IP的价值发挥到极致,接下来,“火星”的网剧、电影等衍生产品也有望陆续亮相。
 相关链接
 栏目推荐
(责任编辑: 于卫亚Android(52)
最近想给自己做的的app添加一个滑动解锁的功能,用的是乐视的手机,就模仿它的效果实现.
2. LockPoint实体
每个点是一个实体(LockPoint)用来存储这个点的所有信息,包括点的物理位置(x,y)和点的index位置(0-8)
class LockPoint {
LockPoint(int index, float x, float y) {
this.index =
LockPoint(LockPoint p) {
this.x = p.x;
this.y = p.y;
this.index = p.
LockPoint() {
this.x = -1;
this.y = -1;
this.index = -1;
boolean isEmpty() {
return this.x == -1 && this.y == -1;
void init(float x, float y) {
void init(LockPoint p) {
this.x = p.x;
this.y = p.y;
this.index = p.
boolean isTouchIn(float judgeX, float judgeY) {
return judgeX & x + touchSensitiveRange &&
judgeX & x - touchSensitiveRange &&
judgeY & y + touchSensitiveRange &&
judgeY & y - touchSensitiveR
public boolean equals(Object o) {
LockPoint p = (LockPoint)
return p.x == x && p.y ==
public int hashCode() {
String out(String tag) {
return tag + " : x = " + x + " , y = " +
初始化九个点的位置,需要根据控件的大小动态计算,因此在onMeare()之后进行
需求是需要将九个点放在控件中间,来适应控件大小的变化,首先确定第一个点距离左边的距离startSpace,两个点之间的距离 =(控件宽度 - 2 * startSpace)/2
int size = getMeasuredWidth();
setMeasuredDimension(size, size);
initLockPointArray = new LockPoint[9];
if (startSpace == AUTO_START_SPACING) {
startSpace = size / 4;
internalSpace = (size - 2 * startSpace) / 2;
初始化九个点的位置
int index = 0;
for (int i = 0; i & 3; i++) {
for (int j = 0; j & 3; j++) {
initLockPointArray[index] = new LockPoint(index, startSpace + j * internalSpace, startSpace + i * internalSpace);
onMeasure()完整代码
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int size = getMeasuredWidth();
setMeasuredDimension(size, size);
if (initLockPointArray == null) {
initLockPointArray = new LockPoint[9];
if (startSpace == AUTO_START_SPACING) {
startSpace = size / 4;
internalSpace = (size - 2 * startSpace) / 2;
int index = 0;
for (int i = 0; i & 3; i++) {
for (int j = 0; j & 3; j++) {
initLockPointArray[index] = new LockPoint(index, startSpace + j * internalSpace, startSpace + i * internalSpace);
if (isInEditMode()) {
historyPointList.addAll(Arrays.asList(initLockPointArray));
绘制过程大致分为三个步骤
&1& 绘制九个点,这是每次都需要绘制的
LockPoint tempP
for (int i = 0; i & initLockPointArray. i++) {
canvas.drawCircle(initLockPointArray[i].x, initLockPointArray[i].y, pointRadius, pointPaint);
&2& 绘制已经划过的点
if (historyPointList.size() & 0) {
for (int i = 0; i & historyPointList.size() - 1; i++) {
canvas.drawLine(historyPointList.get(i).x, historyPointList.get(i).y, historyPointList.get(i + 1).x, historyPointList.get(i + 1).y, linePaint);
&3& 绘制触摸点和最后一个点的连线
if (currentLockPoint != null
&& currentLockPoint.x != -1 && currentLockPoint.y != -1
&& touchPoint.x != -1 && touchPoint.y != -1) {
canvas.drawLine(currentLockPoint.x, currentLockPoint.y, touchPoint.x, touchPoint.y, linePaint);
5. 事件处理
对用户touch事件进行处理
要记录当前触摸的点,用于绘制跟随手指的连线
检测触摸的点是不是在九个点中某个点的范围内,如果是的话该点要加入被触摸点的列表中
当手指抬起时,清除数据,恢复初始状态
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled() || isEventOver)
return false;
int action = MotionEventCompat.getActionMasked(event);
switch (action) {
case MotionEvent.ACTION_DOWN:
touchPoint.init(event.getX(), event.getY());
case MotionEvent.ACTION_MOVE:
touchPoint.init(event.getX(), event.getY());
LockPoint tempP
for (int i = 0; i & initLockPointArray. i++) {
tempPoint = initLockPointArray[i];
if (!historyPointList.contains(tempPoint)
&& tempPoint.isTouchIn(event.getX(), event.getY())) {
historyPointList.add(new LockPoint(tempPoint));
currentLockPoint.init(tempPoint);
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
touchPoint.init(-1, -1);
currentLockPoint.init(-1, -1);
historyPointList.clear();
postInvalidate();
return true;
6. 优化-多点触控事件处理
用户在触摸屏幕时可能有多个手指在操作,上面的代码在单指时没有问题,兼容多点触控的思路是:
当用户触发down事件时,我们可以获取到一个pointerId,这个id唯一的标志了这个指头,后面发生的所有事件都使用用这个pointerId来获取,只处理这个指头的事件,避免事件的错乱。
当我们开始的时候标志的那个手指抬起来了怎么办呢,两个解决方法,第一个就是直接结束整个流程,相当于单指时手指抬起。第二个方法就是转移事件,当一个指头抬起时,从该事件中获取还没抬起的手指,更改标志的pointerId,事件就转移到了另一个手指上,我们关心就是新手指的触摸啦
关于对于事件进行处理的相关机制可以看写的都是比较基本的东西,后面慢慢完善,不过理解获取多指的事件9?绰绰有余啦
话不多说,上代码,比较需要注意的地方我都标注在注释中,方便查找
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled() || isEventOver)
return false;
int pointerI
int action = MotionEventCompat.getActionMasked(event);
switch (action) {
case MotionEvent.ACTION_DOWN:
activePointerId = event.getPointerId(0);
pointerIndex = event.findPointerIndex(activePointerId);
touchPoint.init(event.getX(pointerIndex), event.getY(pointerIndex));
case MotionEvent.ACTION_MOVE:
pointerIndex = event.findPointerIndex(activePointerId);
if (pointerIndex & 0) {
Log.e(TAG, "Got ACTION_MOVE event but have an invalid active pointer id.");
cancelLockDraw();
return false;
touchPoint.init(event.getX(pointerIndex), event.getY(pointerIndex));
LockPoint tempP
for (int i = 0; i & initLockPointArray. i++) {
tempPoint = initLockPointArray[i];
if (!historyPointList.contains(tempPoint)
&& tempPoint.isTouchIn(event.getX(pointerIndex), event.getY(pointerIndex))) {
LockPoint centerPoint = findCenterPoint(tempPoint);
if (!centerPoint.isEmpty()) {
activePoint(centerPoint);
activePoint(tempPoint);
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(event);
case MotionEvent.ACTION_UP:
pointerIndex = event.findPointerIndex(activePointerId);
if (pointerIndex & 0) {
Log.e(TAG, "Got ACTION_UP event but don't have an active pointer id.");
activePointerId = INVALID_POINTER;
return false;
publishResult();
activePointerId = INVALID_POINTER;
case MotionEvent.ACTION_CANCEL:
cancelLockDraw();
activePointerId = INVALID_POINTER;
postInvalidate();
return true;
转移焦点的方法,在各种控件的源代码中随处可见,我也是拷贝出来直接用的,逻辑不是很复杂
* 当一个手机抬起时,转移焦点
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = MotionEventCompat.getActionIndex(ev);
final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
if (pointerId == activePointerId) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
activePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
* 发布绘制结果
private void publishResult() {
if (listener != null) {
isEventOver = true;
StringBuilder sb = new StringBuilder();
for (LockPoint lockPoint : historyPointList) {
sb.append(lockPoint.index);
String passWd = sb.toString();
boolean isFinish = listener.onFinish(LockView.this, passWd, passWd.length());
if (isFinish) {
touchPoint.init(currentLockPoint);
cancelLockDraw();
isEventOver = false;
cancelLockDraw();
回复初始状态,因为在多处调用了,贴一下
* 结束绘制,恢复初始状态
private void cancelLockDraw() {
touchPoint.init(-1, -1);
currentLockPoint.init(-1, -1);
historyPointList.clear();
postInvalidate();
7. 优化-自动添加两点之间连线上的点
当滑动时越过中间的点之间连接两端,自动查找和添加两点之间的点,手机上的滑动解锁也是这样的逻辑,不然会导致图形很繁琐,不美观而且不符合常见逻辑。也就是说如果当前激发的点和上一个激发的点之间有没有激发的点,那么自动给他激发。
首先如果两个点是相邻的或者是对角线上相邻,那么中间一定不会有空下来的点,需要排除这个情况
* 检测相邻
* p1和p2是否相邻,斜对角也算相邻
private boolean isAdjacentPoint(LockPoint p1, LockPoint p2) {
if ((p1.x == p2.x && Math.abs(p1.y - p2.y) == internalSpace)
|| (p1.y == p2.y && Math.abs(p1.x - p2.x) == internalSpace)
|| (Math.abs(p1.x - p2.x) == internalSpace && Math.abs(p1.y - p2.y) == internalSpace)) {
Log.e(TAG, "相邻点,不处理");
return true;
return false;
然后如何判断一个点位于首尾两个激发点的中间,思路是当这个点在两个点的连线上时且不是首尾两个点就是中间的点。判断的根据是斜率是不是相等,就是初中的数学问题啦。
* 判断c点是不是在p1-p2的直线上
* p1 起始点
* p2 终止点
* 是否在该线上
private boolean isInLine(LockPoint p1, LockPoint p2, LockPoint c) {
float k1 = (p1.x - p2.x) * 1f / (p1.y - p2.y);
float k2 = (p1.x - c.x) * 1f / (p1.y - c.y);
return k1 == k2;
最后整合一下,去掉不必要的判断,在touch事件中调用
* 检测当前激活的点和上一个激活点之间的是否有没有激发的点
* activePoint 当前被激发的点
* 当前激活的点和上一个激活点之间的是否有没有激发的点,没有返回empty的{@link LockPoint#isEmpty()}
private LockPoint findCenterPoint(LockPoint activePoint) {
LockPoint rstPoint = new LockPoint();
if (historyPointList.size() & 1) {
return rstP
LockPoint tempP
LockPoint preActivePoint = historyPointList.get(historyPointList.size() - 1);
if (isAdjacentPoint(preActivePoint, activePoint))
return rstP
for (int i = 0; i & initLockPointArray. i++) {
tempPoint = initLockPointArray[i];
if (!historyPointList.contains(tempPoint) && !preActivePoint.equals(tempPoint) && !activePoint.equals(tempPoint)) {
if (isInLine(preActivePoint, activePoint, tempPoint)) {
Log.e(TAG, "点在线上 " + tempPoint.out("temp") + " " + preActivePoint.out("pre") + " " + activePoint.out("active"));
rstPoint.init(tempPoint);
return rstP
在onTouchEvent中调用
LockPoint centerPoint = findCenterPoint(tempPoint);
if (!centerPoint.isEmpty()) {
activePoint(centerPoint);
activePoint(tempPoint);
8. 优化-给被触摸的点添加动画
当手指触摸到一个点时,添加一个缩放动画来反馈触摸操作
思路时,当触摸到一个点时使用ValueAnimator开启动画,不断改变半径的值,在绘制时达到实现缩放的效果
* 开始缩放动画
private void startScaleAnimation() {
if (mScaleAnimator == null) {
mScaleAnimator = ValueAnimator.ofFloat(1f, scaleMax, 1f);
mScaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
float scale = (float) animation.getAnimatedValue();
scalePointRadius = pointRadius *
postInvalidate();
mScaleAnimator.addListener(new Animator.AnimatorListener() {
public void onAnimationStart(Animator animation) {
public void onAnimationEnd(Animator animation) {
scalePointRadius = pointR
public void onAnimationCancel(Animator animation) {
public void onAnimationRepeat(Animator animation) {
mScaleAnimator.setDuration(scaleAnimDuration);
if (mScaleAnimator.isRunning())
mScaleAnimator.end();
mScaleAnimator.start();
同时在onDraw()方法中对刚刚触摸的点要进行绘制,更改onDraw()方法中绘制九个点的部分,对刚刚触摸的点使用缩放后的半径绘制。
LockPoint tempP
for (int i = 0; i & initLockPointArray. i++) {
tempPoint = initLockPointArray[i];
if (currentLockPoint != null && currentLockPoint.equals(tempPoint)) {
canvas.drawCircle(tempPoint.x, tempPoint.y, scalePointRadius, pointPaint);
canvas.drawCircle(tempPoint.x, tempPoint.y, pointRadius, pointPaint);
使用监听将结果回调给使用者,在ACTION_UP时发布结果
public interface OnLockFinishListener {
* lockView 控件
* passWd 密码
* passWsLength 密码长度
* 当返回true时,画面将会定格在绘制结束后的状态,比如当密码输入正确的时候
* 返回false时,画面会重新初始化回初始状态,比如密码重新二次输入确认或者密码错误的时候
boolean onFinish(LockView lockView, String passWd, int passWsLength);
* 发布绘制结果
private void publishResult() {
if (listener != null) {
isEventOver = true;
StringBuilder sb = new StringBuilder();
for (LockPoint lockPoint : historyPointList) {
sb.append(lockPoint.index);
String passWd = sb.toString();
boolean isFinish = listener.onFinish(LockView.this, passWd, passWd.length());
if (isFinish) {
touchPoint.init(currentLockPoint);
cancelLockDraw();
isEventOver = false;
cancelLockDraw();
还遗留了一个点,就是自动添加中间的点时应该也是有动画效果的,暂时还没做,有空补上吧,希望大家指正。
11. 完整代码
: CdLibsTest
: com.march.cdlibstest.widget
* CreateAt :
* Describe : 自定义控件实现九宫格滑动解锁
* chendong
public class LockView extends View {
public static final String TAG = "LOCK_VIEW";
private static final int INVALID_POINTER = -1;
private static final int AUTO_START_SPACING = -1;
private static final int DEFAULT_MIN_POINT_NUM = 4;
private int activePointerId = INVALID_POINTER;
private int startS
private int internalS
private int pointR
private float scalePointR
private int touchSensitiveR
private int lineW
private int pointC
private int lineC
private float scaleM
private int scaleAnimDuration = 150;
private boolean isEventOver = false;
class LockPoint {
LockPoint(int index, float x, float y) {
this.index =
LockPoint(LockPoint p) {
this.x = p.x;
this.y = p.y;
this.index = p.
LockPoint() {
this.x = -1;
this.y = -1;
this.index = -1;
boolean isEmpty() {
return this.x == -1 && this.y == -1;
void init(float x, float y) {
void init(LockPoint p) {
this.x = p.x;
this.y = p.y;
this.index = p.
boolean isTouchIn(float judgeX, float judgeY) {
return judgeX & x + touchSensitiveRange &&
judgeX & x - touchSensitiveRange &&
judgeY & y + touchSensitiveRange &&
judgeY & y - touchSensitiveR
public boolean equals(Object o) {
LockPoint p = (LockPoint)
return p.x == x && p.y ==
public int hashCode() {
String out(String tag) {
return tag + " : x = " + x + " , y = " +
private ValueAnimator mScaleA
private LockPoint[] initLockPointA
private List&LockPoint& historyPointL
private LockPoint touchP
private LockPoint currentLockP
private Paint lineP
private Paint pointP
private OnLockFinishL
public interface OnLockFinishListener {
* lockView 控件
* passWd 密码
* passWsLength 密码长度
* 当返回true时,画面将会定格在绘制结束后的状态
* 返回false时,画面会重新初始化回初始状态
boolean onFinish(LockView lockView, String passWd, int passWsLength);
public LockView(Context context) {
this(context, null);
public LockView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
public LockView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LockView);
float density = getResources().getDisplayMetrics().
pointRadius = (int) typedArray.getDimension(R.styleable.LockView_lock_pointRadius, (8 * density));
scalePointRadius = pointR
touchSensitiveRange = (int) typedArray.getDimension(R.styleable.LockView_lock_touchSensitiveRange, pointRadius * 3);
startSpace = (int) typedArray.getDimension(R.styleable.LockView_lock_startSpace, AUTO_START_SPACING);
lineWidth = (int) typedArray.getDimension(R.styleable.LockView_lock_lineWidth, (5 * density));
lineColor = typedArray.getColor(R.styleable.LockView_lock_lineColor, Color.WHITE);
pointColor = typedArray.getColor(R.styleable.LockView_lock_pointColor, Color.WHITE);
scaleAnimDuration = typedArray.getInt(R.styleable.LockView_lock_scaleAnimDuration, 180);
scaleMax = typedArray.getFloat(R.styleable.LockView_lock_scaleMax, 2.5f);
typedArray.recycle();
historyPointList = new ArrayList&&();
touchPoint = new LockPoint();
currentLockPoint = new LockPoint();
pointPaint = new Paint();
pointPaint.setAntiAlias(true);
pointPaint.setColor(pointColor);
pointPaint.setStyle(Paint.Style.FILL_AND_STROKE);
linePaint = new Paint();
linePaint.setAntiAlias(true);
linePaint.setStrokeWidth(lineWidth);
linePaint.setColor(lineColor);
linePaint.setStyle(Paint.Style.STROKE);
public void setListener(OnLockFinishListener listener) {
this.listener =
* 开始缩放动画
private void startScaleAnimation() {
if (mScaleAnimator == null) {
mScaleAnimator = ValueAnimator.ofFloat(1f, scaleMax, 1f);
mScaleAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
float scale = (float) animation.getAnimatedValue();
scalePointRadius = pointRadius *
postInvalidate();
mScaleAnimator.addListener(new Animator.AnimatorListener() {
public void onAnimationStart(Animator animation) {
public void onAnimationEnd(Animator animation) {
scalePointRadius = pointR
public void onAnimationCancel(Animator animation) {
public void onAnimationRepeat(Animator animation) {
mScaleAnimator.setDuration(scaleAnimDuration);
if (mScaleAnimator.isRunning())
mScaleAnimator.end();
mScaleAnimator.start();
public boolean onTouchEvent(MotionEvent event) {
if (!isEnabled() || isEventOver)
return false;
int pointerI
int action = MotionEventCompat.getActionMasked(event);
switch (action) {
case MotionEvent.ACTION_DOWN:
activePointerId = event.getPointerId(0);
pointerIndex = event.findPointerIndex(activePointerId);
touchPoint.init(event.getX(pointerIndex), event.getY(pointerIndex));
case MotionEvent.ACTION_MOVE:
pointerIndex = event.findPointerIndex(activePointerId);
if (pointerIndex & 0) {
Log.e(TAG, "Got ACTION_MOVE event but have an invalid active pointer id.");
cancelLockDraw();
return false;
touchPoint.init(event.getX(pointerIndex), event.getY(pointerIndex));
LockPoint tempP
for (int i = 0; i & initLockPointArray. i++) {
tempPoint = initLockPointArray[i];
if (!historyPointList.contains(tempPoint)
&& tempPoint.isTouchIn(event.getX(pointerIndex), event.getY(pointerIndex))) {
LockPoint centerPoint = findCenterPoint(tempPoint);
if (!centerPoint.isEmpty()) {
activePoint(centerPoint);
activePoint(tempPoint);
case MotionEventCompat.ACTION_POINTER_UP:
onSecondaryPointerUp(event);
case MotionEvent.ACTION_UP:
pointerIndex = event.findPointerIndex(activePointerId);
if (pointerIndex & 0) {
Log.e(TAG, "Got ACTION_UP event but don't have an active pointer id.");
activePointerId = INVALID_POINTER;
return false;
publishResult();
activePointerId = INVALID_POINTER;
case MotionEvent.ACTION_CANCEL:
cancelLockDraw();
activePointerId = INVALID_POINTER;
postInvalidate();
return true;
* 发布绘制结果
private void publishResult() {
if (listener != null) {
isEventOver = true;
StringBuilder sb = new StringBuilder();
for (LockPoint lockPoint : historyPointList) {
sb.append(lockPoint.index);
String passWd = sb.toString();
boolean isFinish = listener.onFinish(LockView.this, passWd, passWd.length());
if (isFinish) {
touchPoint.init(currentLockPoint);
cancelLockDraw();
isEventOver = false;
cancelLockDraw();
* 当一个手机抬起时,转移焦点
private void onSecondaryPointerUp(MotionEvent ev) {
final int pointerIndex = MotionEventCompat.getActionIndex(ev);
final int pointerId = MotionEventCompat.getPointerId(ev, pointerIndex);
if (pointerId == activePointerId) {
final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
activePointerId = MotionEventCompat.getPointerId(ev, newPointerIndex);
* 检测当前激活的点和上一个激活点之间的是否有没有激发的点
* activePoint 当前被激发的点
* 当前激活的点和上一个激活点之间的是否有没有激发的点,没有返回empty的{@link LockPoint#isEmpty()}
private LockPoint findCenterPoint(LockPoint activePoint) {
LockPoint rstPoint = new LockPoint();
if (historyPointList.size() & 1) {
return rstP
LockPoint tempP
LockPoint preActivePoint = historyPointList.get(historyPointList.size() - 1);
if (isAdjacentPoint(preActivePoint, activePoint))
return rstP
for (int i = 0; i & initLockPointArray. i++) {
tempPoint = initLockPointArray[i];
if (!historyPointList.contains(tempPoint) && !preActivePoint.equals(tempPoint) && !activePoint.equals(tempPoint)) {
if (isInLine(preActivePoint, activePoint, tempPoint)) {
Log.e(TAG, "点在线上 " + tempPoint.out("temp") + " " + preActivePoint.out("pre") + " " + activePoint.out("active"));
rstPoint.init(tempPoint);
return rstP
* 检测相邻
* p1和p2是否相邻,斜对角也算相邻
private boolean isAdjacentPoint(LockPoint p1, LockPoint p2) {
if ((p1.x == p2.x && Math.abs(p1.y - p2.y) == internalSpace)
|| (p1.y == p2.y && Math.abs(p1.x - p2.x) == internalSpace)
|| (Math.abs(p1.x - p2.x) == internalSpace && Math.abs(p1.y - p2.y) == internalSpace)) {
Log.e(TAG, "相邻点,不处理");
return true;
return false;
* 判断c点是不是在p1-p2的直线上
* p1 起始点
* p2 终止点
* 是否在该线上
private boolean isInLine(LockPoint p1, LockPoint p2, LockPoint c) {
float k1 = (p1.x - p2.x) * 1f / (p1.y - p2.y);
float k2 = (p1.x - c.x) * 1f / (p1.y - c.y);
return k1 == k2;
* 激活该点,该点将会添加到选中点列表中,然后执行动画
* tempPoint 被激活的点
private void activePoint(LockPoint tempPoint) {
historyPointList.add(new LockPoint(tempPoint));
currentLockPoint.init(tempPoint);
startScaleAnimation();
postInvalidate();
public void init() {
isEventOver = false;
cancelLockDraw();
* 结束绘制,恢复初始状态
private void cancelLockDraw() {
touchPoint.init(-1, -1);
currentLockPoint.init(-1, -1);
historyPointList.clear();
postInvalidate();
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int size = getMeasuredWidth();
setMeasuredDimension(size, size);
if (initLockPointArray == null) {
initLockPointArray = new LockPoint[9];
if (startSpace == AUTO_START_SPACING) {
startSpace = size / 4;
internalSpace = (size - 2 * startSpace) / 2;
int index = 0;
for (int i = 0; i & 3; i++) {
for (int j = 0; j & 3; j++) {
initLockPointArray[index] = new LockPoint(index, startSpace + j * internalSpace, startSpace + i * internalSpace);
if (isInEditMode()) {
historyPointList.addAll(Arrays.asList(initLockPointArray));
private void log(Object... objs) {
StringBuilder sb = new StringBuilder();
for (Object obj : objs) {
sb.append(obj.toString()).append("
Log.e(TAG, sb.toString());
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (initLockPointArray == null)
log(currentLockPoint.out("current"), touchPoint.out("touch"));
if (currentLockPoint != null
&& currentLockPoint.x != -1 && currentLockPoint.y != -1
&& touchPoint.x != -1 && touchPoint.y != -1) {
canvas.drawLine(currentLockPoint.x, currentLockPoint.y, touchPoint.x, touchPoint.y, linePaint);
if (historyPointList.size() & 0) {
for (int i = 0; i & historyPointList.size() - 1; i++) {
canvas.drawLine(historyPointList.get(i).x, historyPointList.get(i).y, historyPointList.get(i + 1).x, historyPointList.get(i + 1).y, linePaint);
LockPoint tempP
for (int i = 0; i & initLockPointArray. i++) {
tempPoint = initLockPointArray[i];
if (currentLockPoint != null && currentLockPoint.equals(tempPoint)) {
canvas.drawCircle(tempPoint.x, tempPoint.y, scalePointRadius, pointPaint);
canvas.drawCircle(tempPoint.x, tempPoint.y, pointRadius, pointPaint);
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:34715次
积分:1137
积分:1137
排名:千里之外
原创:74篇
评论:19条
(5)(1)(2)(6)(6)(6)(6)(11)(1)(2)(2)(11)(11)(5)(1)}

我要回帖

更多关于 ipad屏幕滑动解锁设置 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信