简体   繁体   English

自定义视图像android的锁定/解锁屏幕

[英]Custom view like lock/unlock screen of android

I would like to create effects like lock/unlock screen of android. 我想创建像锁定/解锁屏幕的Android效果。 I have attached the screenshot here as well. 我也在这里附上了截图。 In lock screen we have 2 buttons but in my case I am having 3 buttons and the middle button must be draggable. 在锁定屏幕中,我们有2个按钮,但在我的情况下,我有3个按钮,中间按钮必须是可拖动的。

在此输入图像描述

在此输入图像描述

The middle button can be drag to left/right. 中间的按钮可以向左/向右拖动。

I know I have to create custom view for this to work but I don't have any idea about how to drag button left/right with nice effect(animations) which normally any android phone have. 我知道我必须为此工作创建自定义视图,但我不知道如何通过任何Android手机具有良好效果(动画)左/右拖动按钮。

I need guidance on this, so can anyone suggest me how to approach for this. 我需要这方面的指导,所以任何人都可以建议我如何处理这个问题。

Basically i wish to move/slide button left and right and based on that want to take some action. 基本上我希望左右移动/滑动按钮,并希望采取一些行动。

I have tried making a lockscreen application myself and i almost made it, but here are the facts you will have to face at the end 我自己试过制作一个锁屏应用程序而且我几乎已经成功了,但这里有你最后要面对的事实

  1. You will not be able to disable home or menu button. 您将无法禁用主页或菜单按钮。
  2. you will need user permission (not the one you get while installing the application, the menu pops up every time you press the home button unless the user decides to make your application default home screen, if that does happen you have successfully made a lock screen) if you decide to make a home screen application too. 您将需要用户权限(不是您在安装应用程序时获得的权限,每次按主页按钮时都会弹出菜单,除非用户决定将您的应用程序设为默认主屏幕,如果确实发生这种情况您已成功锁定屏幕)如果您决定制作主屏幕应用程序。
  3. the lock screen doesn't go very well with passwords 锁定屏幕与密码不太顺利

But if it helps, here's what i did: 但如果它有帮助,这就是我所做的:

You need to create a service that keeps a check on the screen being off and on. 您需要创建一个服务来检查屏幕是否已关闭。

if the screen is off, you do nothing. 如果屏幕关闭,你什么都不做。 when the screen if ON you start the activity and wait for the user to do the thing you want the user to make him unlock the screen. 当屏幕显示为ON时,您启动活动并等待用户执行您希望用户让他解锁屏幕的事情。 and when he does that you finish() the activity. 当他这样做时,你完成了()活动。

While doing that you need to setup a method that can listen to check the incoming calls you can do that by extending PhoneStateListener and also disable the back button. 在执行此操作时,您需要设置一个可以侦听来电的方法,您可以通过扩展PhoneStateListener并禁用后退按钮来执行此操作。

Good Luck and if you are able to make any further progress do let me know. 祝你好运,如果你有进一步的进展,请告诉我。

Maybe this project could help you GlowPadView . 也许这个项目可以帮助你GlowPadView I've used it succesfully in one project. 我在一个项目中成功地使用了它。 Hope it's what you're looking for. 希望这是你正在寻找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM