Custom view, for example, Android screen lock / unlock

I would like to create effects like Android screen lock / unlock. I also added a screenshot. In lock mode, we have 2 buttons, but in my case I have 3 buttons, and the middle button should be draggable.

enter image description here

enter image description here

The middle button can be dragged left / right.

I know that I need to create a custom view for this, but I donโ€™t know how to drag the button left / right using the nice effect (animation) that any Android phone usually has.

I need guidance on this, so anyone can suggest me how to approach this.

Basically, I want to move / move the button left and right and based on the fact that some action needs to be taken.

+4
source share
2 answers

Perhaps this project can help you with GlowPadView . I used it in one project. Hope this is what you are looking for.

+1
source

I tried to make the lockscreen application on my own, and I almost did it, but here are the facts that you will encounter at the end.

  • You cannot disable the home button or menu button.
  • you need the permission of the user (and not the one that you get when installing the application, the menu appears every time you press the home button, if the user does not decide to make his home screen your default application, if this happens, you successfully made the screen locks) if you also decide to make a home screen application.
  • the lock screen does not work well with passwords

But if that helps, here is what I did:

You need to create a service that keeps the check on the screen turned off and on.

If the screen is off, you are not doing anything. when the screen is on, you start the action and wait for the user to do what you want the user to force him to unlock the screen. and when he does this, you complete () the activity.

In this case, you need to configure a method that can listen to incoming calls, you can do this by expanding PhoneStateListener and disabling the "Back" button.

Good luck, and if you are able to make any further progress, let me know.

+2
source

Source: https://habr.com/ru/post/1501582/


All Articles