4

I would like to create effects like lock/unlock screen of 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.

enter image description here

enter image description here

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.

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.

Carl Veazey
  • 18,392
  • 8
  • 66
  • 81
Scorpion
  • 6,831
  • 16
  • 75
  • 123

2 Answers2

2

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. 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.

Good Luck and if you are able to make any further progress do let me know.

Mayank
  • 1,364
  • 1
  • 15
  • 29
  • I have done it. I am not able to move the image from left to right or right to left.. any idea How can I do this ? – Srikanth Pai Oct 28 '13 at 08:33
  • moving the image is the part of the activity. there are two possible solutions i can think of one is using a seekbar( you can change the thumb for the image) and the other is setting the ontouchlistener on the image and inside the ontouch method use MotionEvent.ACTION_DOWN and use runonuithread to change the coordinates of the image to the coordinates of the touch. – Mayank Oct 29 '13 at 11:24
  • @contactmeandroid could you please upload the code of your project. because i dont have much clue of how you came to solve the password problem. and disable the home button. – Mayank Oct 29 '13 at 11:25
  • 1
    i used the seekbar. but the problem is I cannot prevent the user from clicking the progressDrawble and also I cannot change the height of the background – Srikanth Pai Oct 29 '13 at 11:32
1

Maybe this project could help you GlowPadView. I've used it succesfully in one project. Hope it's what you're looking for.

huizar_mx
  • 51
  • 3
  • @contactmeandroid, can you please share your code so that i can get idea what actually you have done and then i can suggest you how you can swipe it right or left.. – Scorpion Oct 28 '13 at 12:09
  • @Scorpion - Currently I just two ImageViews on either side of the screen and I am using onTouchListner to drag it horzontally. But I am not sure how to get a background when the image is being dragged. Here is my code in the next comment – Srikanth Pai Oct 28 '13 at 16:36
  • @Scorpion left_Locker.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { int eid = event.getAction(); switch (eid) { case MotionEvent.ACTION_MOVE: RelativeLayout.LayoutParams mParams = (RelativeLayout.LayoutParams) left_Locker.getLayoutParams(); int x = (int) event.getRawX(); mParams.leftMargin = x - 50; left_Locker.setLayoutParams(mParams); break; default: break; } return true; } }); – Srikanth Pai Oct 28 '13 at 16:37
  • @Scorpion i am struggling to do this from a week now.. hope you help me out Thanks – Srikanth Pai Oct 29 '13 at 02:27