android實現滑動解鎖_Android

來源:腳本之家  責任編輯:小易  

Android手機去掉系統自帶的滑動解鎖方法如下:1、待機情況下打開菜單欄,選擇設置。2、在設置里選擇鎖定屏幕,進去后點擊屏幕鎖定。3、在進去的菜單欄選擇“無”。4、去掉滑動解鎖完成www.13333515.buzz防采集請勿采集本網。

本文實例為大家分享了android實現滑動解鎖的具體代碼,供大家參考,具體內容如下

1、打開“設置”面板;2、找到“個人”類里的“安全”選項。3、找到選項“屏幕鎖定”選項 4、在“屏幕鎖定”里,選擇“不鎖屏”。5、就這樣,再次喚醒屏幕時就可以直接參考資料:解鎖_百度百科

效果圖

需要用到的畫筆, 整體灰色的背景,  滑塊, 滑動之后綠色背景, 字體 

相機快捷鍵貌似要長按,不要自動鎖屏貌似可以刪除或者安裝別的鎖屏軟件。查看原帖>>

mSliPaint = new Paint();mSliPaint.setColor(Color.parseColor("#4a4c5b"));mSliPaint.setAntiAlias(true); mBgPaint = new Paint();mBgPaint.setColor(Color.parseColor("#a6a6a6"));mBgPaint.setAntiAlias(true); mBluePaint = new Paint();mBluePaint.setColor(Color.parseColor("#009496"));mBluePaint.setAntiAlias(true); mPaint = new Paint();mPaint.setColor(Color.WHITE);mPaint.setTextSize(mTextSize);//該方法即為設置基線上那個點究竟是left,center,還是rightmPaint.setTextAlign(Paint.Align.LEFT);

下一個RE管理器 然后找文件夾System 再找文件夾APP 就在里面直接刪了解鎖文件 那個圖標很明顯

在onDraw中繪制  mMovex為手指滑動的X坐標

360手機衛士里有個工具箱-智能鎖屏-點擊關閉。我的是這樣關掉了一個,保留了手機本身的

@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); //背景色 RectF oval = new RectF(margin, margin, width - margin, height - margin);// 設置個新的長方形 canvas.drawRect(oval,mBgPaint); //劃過去背景色 RectF ovalBlue= new RectF(margin,margin,mMoveX+margin,mR*2+margin*3); canvas.drawRect(ovalBlue,mBluePaint); //文字 Paint.FontMetrics fontMetrics = mPaint.getFontMetrics(); float top = fontMetrics.top;//為基線到字體上邊框的距離 float bottom = fontMetrics.bottom;//為基線到字體下邊框的距離 int baseLineY = (int) (height / 2 - top / 2 - bottom / 2);//基線中間點的y軸計算公式 canvas.drawText(mText, mTextLeft, baseLineY, mPaint); //滑塊 RectF oval2 = new RectF(mMoveX+margin,margin,mMoveX+mR*3+margin*3,mR*2+margin*3);// 設置個新的長方形 canvas.drawRect(oval2,mSliPaint);//方形 //三個小箭頭 Bitmap bitmap = BitmapFactory.decodeResource(this.getContext().getResources(), R.mipmap.arrow_right_small); canvas.drawBitmap(bitmap,mMoveX+(mMoveX+mR*3+margin*3-mMoveX)/2-15,mR-margin,mSliPaint); canvas.drawBitmap(bitmap,mMoveX+(mMoveX+mR*3+margin*3-mMoveX)/2,mR-margin,mSliPaint); canvas.drawBitmap(bitmap,mMoveX+(mMoveX+mR*3+margin*3-mMoveX)/2+15,mR-margin,mSliPaint); }

更改手機鎖屏密碼,建議進行以下操作: 1、打開手機設定 2、選擇鎖定屏幕 3、屏幕安全性 4、屏幕鎖定 5、輸入之前設置的密碼 6、選擇需要的鎖屏方式重新設置即可 7、如果無需鎖屏選擇無即可

onTouch中進行滑動監聽 負值

@Overridepublic boolean onTouchEvent(MotionEvent event) { // Log.e(event.getAction()+""); // 點擊是否在滑塊上 if (event.getAction() != MotionEvent.ACTION_DOWN && !mSliderRect.contains((int) mStartX, (int) mStartY)) { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { mHandler.sendEmptyMessageDelayed(MSG_REDRAW, DRAW_INTERVAL); } return super.onTouchEvent(event); } acquireVelocityTrackerAndAddMovement(event); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mStartX = event.getX(); mStartY = event.getY(); mLastX = mStartX; mHandler.removeMessages(MSG_REDRAW);// L.e("按下"); Log.e("SlideU","按下"); break; case MotionEvent.ACTION_MOVE: Log.e("SlideU","移動"); mLastX = event.getX(); if (mLastX > mStartX) { if (mLastX - mStartX > mSlidableLength) { mLastX = mStartX + mSlidableLength; mMoveX = mSlidableLength; } else { mMoveX = (int) (mLastX - mStartX); } } else { mLastX = mStartX; mMoveX = 0; } invalidate(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: Log.e("SlideU","超出或抬起"); mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity); float velocityX = mVelocityTracker.getXVelocity(); Log.e("SlideU","速度"+velocityX); if (mLastX - mStartX > mEffectiveLength || velocityX/2 > mEffectiveVelocity) { startAnimator(mLastX - mStartX, mSlidableLength, velocityX, true); } else { startAnimator(mLastX - mStartX, 0, velocityX, false); mHandler.sendEmptyMessageDelayed(MSG_REDRAW, DRAW_INTERVAL); } releaseVelocityTracker(); break; } return super.onTouchEvent(event); }

整體代碼

public class LoadAwaySlideUnlockView extends View { public interface UnlockListener { void onLoadAwayUnlock(); } private UnlockListener mUnlockListener; public void setUnlockListener(UnlockListener unlockListener) { mUnlockListener = unlockListener; } private static final int MSG_REDRAW = 1; private static final int DRAW_INTERVAL = 50; private static final int STEP_LENGTH = 10;//速度 private Paint mPaint;//文字的畫筆 private Paint mSliPaint;//滑塊畫筆 private Paint mBgPaint;//背景畫筆 private Paint mBluePaint;//劃過去之后藍色背景的畫筆 private VelocityTracker mVelocityTracker;//滑動速度 private int mMaxVelocity; private LinearGradient mGradient;//漸變色 private LinearGradient bgGradient;//背景漸變色// private LinearGradient sliGradient;//滑塊漸變色// LinearGradient有兩個構造函數;//// public LinearGradient(float x0, float y0, float x1, float y1, int[] colors, float[] positions,Shader.TileMode tile)//// 參數://// float x0: 漸變起始點x坐標//// float y0:漸變起始點y坐標//// float x1:漸變結束點x坐標//// float y1:漸變結束點y坐標//// int[] colors:顏色 的int 數組//// float[] positions: 相對位置的顏色數組,可為null, 若為null,可為null,顏色沿漸變線均勻分布//// Shader.TileMode tile: 渲染器平鋪模式//////// public LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1,Shader.TileMode tile)//// float x0: 漸變起始點x坐標//// float y0:漸變起始點y坐標//// float x1:漸變結束點x坐標//// float y1:漸變結束點y坐標//// int color0: 起始漸變色// int color1: 結束漸變色//// Shader.TileMode tile: 渲染器平鋪模式 private int[] mGradientColors; private int[] bgGradientColors; private int mGradientIndex; private Interpolator mInterpolator; private float mDensity; private Matrix mMatrix; private ValueAnimator mValueAnimator; private int width; private int height; private String mText;//文字 private int mTextSize;//文字大小 private int mTextLeft;//文字距離左邊 private int mR;//滑塊的半徑 private float margin; private Rect mSliderRect; private int mSlidableLength; // SlidableLength = BackgroundWidth - LeftMagins - RightMagins - SliderWidth private int mEffectiveLength; // Suggested length is 20pixels shorter than SlidableLength private float mEffectiveVelocity = 1000;//滑塊自動回滾的速度 private float mStartX; private float mStartY; private float mLastX; private float mMoveX; public LoadAwaySlideUnlockView(Context context) { this(context, null); } public LoadAwaySlideUnlockView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public LoadAwaySlideUnlockView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public void setText(String text){ mText = text; } public LoadAwaySlideUnlockView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); mDensity = getResources().getDisplayMetrics().density; ViewConfiguration configuration = ViewConfiguration.get(context); mMaxVelocity = configuration.getScaledMaximumFlingVelocity(); mInterpolator = new AccelerateDecelerateInterpolator(); setClickable(true); setFocusable(true); setFocusableInTouchMode(true); mSlidableLength = 200; mTextSize = 30;//文字大小 mTextLeft = 10;//文字距離左邊 mMoveX = 0; mGradientIndex = 0; mSliPaint = new Paint(); mSliPaint.setColor(Color.parseColor("#4a4c5b")); mSliPaint.setAntiAlias(true); mBgPaint = new Paint(); mBgPaint.setColor(Color.parseColor("#a6a6a6")); mBgPaint.setAntiAlias(true); mBluePaint = new Paint(); mBluePaint.setColor(Color.parseColor("#009496")); mBluePaint.setAntiAlias(true); mPaint = new Paint(); mPaint.setColor(Color.WHITE); mPaint.setTextSize(mTextSize); //該方法即為設置基線上那個點究竟是left,center,還是right mPaint.setTextAlign(Paint.Align.LEFT); // mHandler.sendEmptyMessageDelayed(MSG_REDRAW, DRAW_INTERVAL); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int specWidthSize = MeasureSpec.getSize(widthMeasureSpec);//寬 int specHeightSize = MeasureSpec.getSize(heightMeasureSpec);//高 mMatrix = new Matrix(); width = specWidthSize; height = specHeightSize; mTextLeft = (int) (height * 1.5); margin = height / 20; mR = (int) (((height-margin*2) / 2)-margin); //最大滑動距離 mSlidableLength = (int) (specWidthSize -(mMoveX+mR*3+margin*3-mMoveX+margin)); //有效距離 mEffectiveLength = mSlidableLength-20; mSliderRect=new Rect((int)margin, (int)margin, 300, (int)(height - margin)); mGradientColors = new int[]{Color.argb(255, 120, 120, 120), Color.argb(255, 120, 120, 120), Color.argb(255, 255, 255, 255)}; mGradient = new LinearGradient(0, 0, width/2, 0, mGradientColors, new float[]{0, 0.7f, 1}, Shader.TileMode.MIRROR); bgGradient = new LinearGradient( 0, 0, 0, (float) ((height)/2.0), Color.argb(80, 0X77, 0X77, 0X77), Color.argb(200, 0X11, 0X11, 0X11), Shader.TileMode.CLAMP ); mHandler.removeMessages(MSG_REDRAW); mHandler.sendEmptyMessageDelayed(MSG_REDRAW, DRAW_INTERVAL); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); //背景色 RectF oval = new RectF(margin, margin, width - margin, height - margin);// 設置個新的長方形 canvas.drawRect(oval,mBgPaint); //劃過去背景色 RectF ovalBlue= new RectF(margin,margin,mMoveX+margin,mR*2+margin*3); canvas.drawRect(ovalBlue,mBluePaint); //文字 Paint.FontMetrics fontMetrics = mPaint.getFontMetrics(); float top = fontMetrics.top;//為基線到字體上邊框的距離 float bottom = fontMetrics.bottom;//為基線到字體下邊框的距離 int baseLineY = (int) (height / 2 - top / 2 - bottom / 2);//基線中間點的y軸計算公式 canvas.drawText(mText, mTextLeft, baseLineY, mPaint); //滑塊 RectF oval2 = new RectF(mMoveX+margin,margin,mMoveX+mR*3+margin*3,mR*2+margin*3);// 設置個新的長方形 canvas.drawRect(oval2,mSliPaint);//方形 //三個小箭頭 Bitmap bitmap = BitmapFactory.decodeResource(this.getContext().getResources(), R.mipmap.arrow_right_small); canvas.drawBitmap(bitmap,mMoveX+(mMoveX+mR*3+margin*3-mMoveX)/2-15,mR-margin,mSliPaint); canvas.drawBitmap(bitmap,mMoveX+(mMoveX+mR*3+margin*3-mMoveX)/2,mR-margin,mSliPaint); canvas.drawBitmap(bitmap,mMoveX+(mMoveX+mR*3+margin*3-mMoveX)/2+15,mR-margin,mSliPaint); } public void reset() { if (mValueAnimator != null) { mValueAnimator.cancel(); } mMoveX = 0; mPaint.setAlpha(255); mHandler.removeMessages(MSG_REDRAW); mHandler.sendEmptyMessageDelayed(MSG_REDRAW,200); } @Override public boolean onTouchEvent(MotionEvent event) { // Log.e(event.getAction()+""); // 點擊是否在滑塊上 if (event.getAction() != MotionEvent.ACTION_DOWN && !mSliderRect.contains((int) mStartX, (int) mStartY)) { if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { mHandler.sendEmptyMessageDelayed(MSG_REDRAW, DRAW_INTERVAL); } return super.onTouchEvent(event); } acquireVelocityTrackerAndAddMovement(event); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mStartX = event.getX(); mStartY = event.getY(); mLastX = mStartX; mHandler.removeMessages(MSG_REDRAW);// L.e("按下"); Log.e("SlideU","按下"); break; case MotionEvent.ACTION_MOVE: Log.e("SlideU","移動"); mLastX = event.getX(); if (mLastX > mStartX) { if (mLastX - mStartX > mSlidableLength) { mLastX = mStartX + mSlidableLength; mMoveX = mSlidableLength; } else { mMoveX = (int) (mLastX - mStartX); } } else { mLastX = mStartX; mMoveX = 0; } invalidate(); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: Log.e("SlideU","超出或抬起"); mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity); float velocityX = mVelocityTracker.getXVelocity(); Log.e("SlideU","速度"+velocityX); if (mLastX - mStartX > mEffectiveLength || velocityX/2 > mEffectiveVelocity) { startAnimator(mLastX - mStartX, mSlidableLength, velocityX, true); } else { startAnimator(mLastX - mStartX, 0, velocityX, false); mHandler.sendEmptyMessageDelayed(MSG_REDRAW, DRAW_INTERVAL); } releaseVelocityTracker(); break; } return super.onTouchEvent(event); } private void startAnimator(float start, float end, float velocity, boolean isRightMoving) { if (velocity < mEffectiveVelocity) { velocity = mEffectiveVelocity; } int duration = (int) (Math.abs(end - start) * 1000 / velocity); mValueAnimator = ValueAnimator.ofFloat(start, end); mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mMoveX = (Float) animation.getAnimatedValue(); invalidate(); } }); mValueAnimator.setDuration(duration); mValueAnimator.setInterpolator(mInterpolator); if (isRightMoving) { mValueAnimator.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) {// L.e("解鎖"); Log.e("SlideU","解鎖"); if (mUnlockListener != null) { mUnlockListener.onLoadAwayUnlock(); } } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); } mValueAnimator.start(); } private void acquireVelocityTrackerAndAddMovement(MotionEvent ev) { if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(ev); } private void releaseVelocityTracker() { if (mVelocityTracker != null) { mVelocityTracker.recycle(); mVelocityTracker = null; } } private Handler mHandler = new Handler() { public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case MSG_REDRAW: if(mMatrix==null){ mMatrix = new Matrix(); } mMatrix.setTranslate(mGradientIndex, 0); if(mGradient==null){// L.e("mGradient空"); mGradientColors = new int[]{Color.argb(255, 120, 120, 120), Color.argb(255, 120, 120, 120), Color.argb(255, 255, 255, 255)}; mGradient = new LinearGradient(0, 0, width/2, 0, mGradientColors, new float[]{0, 0.7f, 1}, Shader.TileMode.MIRROR); } mGradient.setLocalMatrix(mMatrix); invalidate(); mGradientIndex += STEP_LENGTH ; if(mGradientIndex>=Integer.MAX_VALUE){ mGradientIndex = 0; } mHandler.sendEmptyMessageDelayed(MSG_REDRAW, DRAW_INTERVAL); break; } } };}

xml布局

<xxxx.LoadAwaySlideUnlockView android:id="@+id/slideUnlock" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_width="match_parent" android:layout_height="56dp"/>

activity中 添加提示文字和滑動監聽即可

slideUnlock.setText("中間提示文字");slideUnlock.setSlideListener(this);

安卓手機滑動解鎖的設置方法:第一步:點開【設置】;第二步:找到【安全與隱私】,點開;第三步:點開【屏幕安全保護】;第四步:點開【屏幕密碼】;第五步:設置手勢屏幕密碼,完成內容來自www.13333515.buzz請勿采集。


  • 本文相關:
  • android模擬實現滑動解鎖界面
  • android 自定義textview實現滑動解鎖高亮文字
  • android自定義滑動解鎖控件使用詳解
  • 使用android自定義控件實現滑動解鎖九宮格
  • android滑動解鎖震動效果的開啟和取消
  • android 九宮格滑動解鎖開機實例源碼學習
  • android喚醒、解鎖屏幕代碼實例
  • android點亮屏幕或屏幕解鎖和鎖定以及其他相關權限實現代碼
  • android編程實現禁止系統鎖屏與解鎖亮屏的方法
  • android中判斷屏幕是否亮屏和是否解鎖功能
  • android多邊形區域遞歸種子填充算法的示例代碼
  • android學習筆記--使用剪切板在activity中傳值示例代碼
  • android 中rxpermissions 的使用方法詳解
  • react-native android 與 ios app使用一份代碼實現方法
  • android系統永不鎖屏永不休眠的方法
  • android底部菜單欄實現的實例代碼
  • android自定義view仿ios圓盤時間選擇器
  • android編程開發之多點觸摸(multitouch)實現方法
  • android簡單實現彈幕效果
  • android修改自己程序字體的方法詳解
  • 安卓手機滑動解鎖怎么設置啊
  • android 如何去掉滑動解鎖
  • 手機屏幕出現了向右滑動解鎖方式,并跳出了快報等信息,顯得很亂,如何取消?
  • Android 怎么編向右滑動解鎖
  • 安卓手機如何去掉滑動解鎖?
  • Android系統可以不用滑動解鎖·直接使用嗎?
  • android怎么去掉滑動解鎖
  • 手機上有兩個滑動解鎖屏怎樣去掉一個
  • android手機如何去掉滑動解鎖
  • 關于安卓系統的滑動解鎖!
  • 網站首頁網頁制作腳本下載服務器操作系統網站運營平面設計媒體動畫電腦基礎硬件教程網絡安全c#教程vbvb.netc 語言java編程delphijavaandroidiosswiftscala易語言匯編語言其它相關首頁androidandroid模擬實現滑動解鎖界面android 自定義textview實現滑動解鎖高亮文字android自定義滑動解鎖控件使用詳解使用android自定義控件實現滑動解鎖九宮格android滑動解鎖震動效果的開啟和取消android 九宮格滑動解鎖開機實例源碼學習android喚醒、解鎖屏幕代碼實例android點亮屏幕或屏幕解鎖和鎖定以及其他相關權限實現代碼android編程實現禁止系統鎖屏與解鎖亮屏的方法android中判斷屏幕是否亮屏和是否解鎖功能android多邊形區域遞歸種子填充算法的示例代碼android學習筆記--使用剪切板在activity中傳值示例代碼android 中rxpermissions 的使用方法詳解react-native android 與 ios app使用一份代碼實現方法android系統永不鎖屏永不休眠的方法android底部菜單欄實現的實例代碼android自定義view仿ios圓盤時間選擇器android編程開發之多點觸摸(multitouch)實現方法android簡單實現彈幕效果android修改自己程序字體的方法詳解一看就懂的android app開發入門教微信公眾平臺開發入門教程(圖文詳android基礎之使用fragment控制切六款值得推薦的android(安卓)開android textview設置中文字體加android應用開發sharedpreferencandroid 動畫之translateanimatiandroid壓力測試命令monkey詳解android按鈕單擊事件的四種常用寫android調試工具ddms的使用詳解android單選按鈕radiobutton的使用詳解listview中button搶占焦點的解決方法android中一種巧妙的drawable.xml替代方案android用scroller實現一個可向上滑動的底android實現自動截圖腳本androidq(10)分區存儲完美適配方法android屬性動畫之valueanimator代碼詳解android實現跑馬燈效果的方法android之progressbar即時顯示下載進度詳詳解android checkbox的使用方法
    免責聲明 - 關于我們 - 聯系我們 - 廣告聯系 - 友情鏈接 - 幫助中心 - 頻道導航
    Copyright © 2017 www.13333515.buzz All Rights Reserved
    3排列五开奖结果