Android slider button widget - android

I am a newbie of Android development. I want to implement a sliding button with animation. The effect is shown in the following video: http://www.youtube.com/watch?v=ImHe4N4mvE4. This is like "slide to unlock" effect of iphone. My question is that how to impelment this kind of effect. Is this app implemented with changeview, scrollview ?

you can put an image view with animation in a linear layout whose height is wrap content and width is fill parent
code for animation
public static Animation inFromLeftAnimation() {
Animation inFromLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromLeft.setDuration(350);
inFromLeft.setInterpolator(new AccelerateInterpolator());
return inFromLeft;
}
public static Animation outToLeftAnimation() {
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
outtoLeft.setDuration(350);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}

Related

how to achieve this kind of animation in android?

tried animations for a cardview in horizontal recycler view, but no luck!!!!
private Animation inFromTopAnimation() {
Animation inFromTop = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromTop.setDuration(500);
inFromTop.setInterpolator(new AccelerateInterpolator());
return inFromTop;
}
I got the solution for the question, which is similar.https://github.com/Cleveroad/FanLayoutManager

Android How to Animate Translate Inflate Layout set Start Magin From top

animation = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.ABSOLUTE, -300, Animation.ABSOLUTE, 0
I use this code. but i want magin top between start inflate layout and top screen.
how to code it.

View animation right to left android

I am not able to put view animation for inflated layouts.
I used the following code snippet
pageView.startAnimation(AnimationUtils.loadAnimation(this,R.anim.right_to_left_anim.xml));
and xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="0%" android:toXDelta="100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
</set>
Is any thing i missing?
Thanks.
Here is the code for the sliding animation for view.
1)inFromRightAnimation
private Animation inFromRightAnimation() {
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(500);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}
2)outToLeftAnimation
private Animation outToLeftAnimation() {
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
outtoLeft.setDuration(500);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}
3)inFromLeftAnimation
private Animation inFromLeftAnimation() {
Animation inFromLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromLeft.setDuration(500);
inFromLeft.setInterpolator(new AccelerateInterpolator());
return inFromLeft;
}
4)outToRightAnimation
private Animation outToRightAnimation() {
Animation outtoRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
outtoRight.setDuration(500);
outtoRight.setInterpolator(new AccelerateInterpolator());
return outtoRight;
}
and now start Animation on view
pageView.startAnimation(inFromRightAnimation());
Thanks,
If you're trying to animate the view when it's first created, then you either need to set the layoutAnimation XML property or call setLayoutAnimation().
If you just want to make your view look like it's moving, you need a TranslateAnimation; see this answer: https://stackoverflow.com/a/4214490/832776
Also if you'd like to repeat the animation, then call setAnimationListener() and in onAnimationEnd() just start the animation again.
If you're trying to move the view permanently, see this: http://www.clingmarks.com/how-to-permanently-move-view-with-animation-effect-in-android/400
I know that you have already accepted the answer. But I think this reply will be helpful for somebody reading this. You can try removing .xml from, pageView.startAnimation(AnimationUtils.loadAnimation(this,R.anim.right_to_left_anim.xml));

Android animation moves layout from right to left

I use a animation to move a layout from right to left.
The animation doesn't work correctly. When the view is moving, the bottom and right edges of moving view are painted on screen as the follow picture show.
Does anyone know the reason and how to fix this problem? thanks!
refer that link here. That animation work on list view adapter and activity. u just try it.
private Animation inFromRightAnimation() {
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(500);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}

swipe images in android

I need a little information about how to do a swipe image viewer for Android.Something exactly like this : http://www.photoswipe.com/latest/examples/jquery-mobile.html#&ui-state=dialog .I'm have a listView and I want every time i click an listview item it opens a new windows with the selected image in fullscreen and when I tab on the image,the bottom part with the left right button shows up and some information above the image.In a fullscreen mode I want to be able to swipe left and right and different image shows up.
Any idea how to do this?Thanks a lot!
Insert imageviews inside a viewflipper (here is is called optionsVF)
In your onClick or something:
Animation in = AnimationFactory.inFromRight();
in.setDuration(500);
optionsVF.setInAnimation(in);
Animation out = AnimationFactory.outToLeft();
out.setDuration(500);
optionsVF.setOutAnimation(out);
optionsVF.showNext();
my class :) AnimationFactory
/*
* Copyright 2011 Sherif
*/
public class AnimationFactory {
public static Animation inFromRight() {
Animation inFromLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromLeft.setDuration(500);
inFromLeft.setInterpolator(new AccelerateInterpolator());
return inFromLeft;
}
public static Animation outToLeft() {
Animation inFromLeft = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f
);
inFromLeft.setDuration(500);
inFromLeft.setInterpolator(new AccelerateInterpolator());
return inFromLeft;
}
}

Categories

Resources