I need to place a button similar to the one on the home screen that slides with your finger to unlock the mobiles.
I refer specifically to this:
Searching for Android-Arsenal I have not found anything.
Two methods come to mind. One use drag-drop but not if you can restrict the zone in moving the element and until it reaches destination B does not launch the event.
The second is to use the SeekBar component, customize it a bit and in the OnSeekBarChangeListener
saber% event that is moving, if you stop pressing, you can go back to the beginning.
<SeekBar
android:id="@+id/myseek"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:max="100"
android:progressDrawable="@android:color/transparent"
android:thumb="@drawable/ic_launcher" />
and in java
sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (seekBar.getProgress() > 95) {
} else {
seekBar.setThumb(getResources().getDrawable(R.drawable.ic_launcher));
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
if(progress>95){
seekBar.setThumb(getResources().getDrawable(R.drawable.load_img1));
}
}
});
Solution extracted from How to make slide to unlock button in android (en)