日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

快速实现手势解锁功能

發布時間:2025/3/17 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 快速实现手势解锁功能 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

添加 PatternLock 到項目

  • 第一步: 添加 JitPack 到項目的根 build.gradle 中
allprojects {repositories {...maven { url 'https://jitpack.io' }} } 復制代碼
  • 第二步:添加庫依賴
dependencies {implementation 'com.github.huangziye:PatternLock:${latest_version}' } 復制代碼
  • 在 xml 中編寫
<com.hzy.lock.PatternLockViewandroid:id="@+id/mPatternLockView"android:layout_width="280dp"android:layout_height="280dp"android:layout_gravity="center_horizontal"android:layout_marginTop="16dp"app:aspectRatio="square"app:aspectRatioEnabled="true"app:dotAnimationDuration="150"app:dotCount="3"app:dotNormalSize="10dp"app:dotSelectedSize="24dp"app:normalStateColor="@color/colorPrimary"app:correctStateColor="@color/colorPrimary"app:wrongStateColor="@color/pomegranate"app:pathEndAnimationDuration="100"app:pathWidth="3dp"/> 復制代碼
  • 用 kotlin 代碼實現
private fun initPatternLockView() {//設置橫縱坐標點的個數mPatternLockView.setDotCount(3)//設置未選中點的大小mPatternLockView.setDotNormalSize(ResourceUtil.getDimensionInPx(this,R.dimen.pattern_lock_dot_size) as Int)//設置選中時點的大小mPatternLockView.setDotSelectedSize(ResourceUtil.getDimensionInPx(this,R.dimen.pattern_lock_dot_selected_size) as Int)//設置路徑線的寬度mPatternLockView.setPathWidth(ResourceUtil.getDimensionInPx(this,R.dimen.pattern_lock_path_width) as Int)//設置寬高比是否啟用mPatternLockView.setAspectRatioEnabled(true)//設置寬高比mPatternLockView.setAspectRatio(PatternLockView.AspectRatio.ASPECT_RATIO_HEIGHT_BIAS)//設置View的模式mPatternLockView.setViewMode(PatternLockView.PatternViewMode.CORRECT)//設置點動畫持續時間mPatternLockView.setDotAnimationDuration(150)// 設置Pat結束動畫持續時間mPatternLockView.setPathEndAnimationDuration(100)//設置正確的狀態顏色mPatternLockView.setCorrectStateColor(ResourceUtil.getColor(this, R.color.colorPrimary))//是否設置為隱身模式mPatternLockView.setInStealthMode(false)//設置是否啟用觸覺反饋mPatternLockView.setTactileFeedbackEnabled(true)//設置輸入是否啟用mPatternLockView.setInputEnabled(true)mPatternLockView.addPatternLockListener(mPatternLockViewListener) } 復制代碼

效果預覽


關于我

  • 簡書

  • 掘金

  • Github


License

Copyright 2018, huangziyeLicensed 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 athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License. 復制代碼

總結

以上是生活随笔為你收集整理的快速实现手势解锁功能的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。