How to do webview animation in android - android

suppose i have three text as heading.Any how you can take textview or anything.one text on left,one in center and one in right side.so i want an animation when i will slide the screen left then left text will be gone,center text will come to left and right text will come to center.Same thing for right slide.Can anyone suggest how can i achieve this type of animation.Plz help.

You can try to create an animation variable :
private Animation leftAnimation() {
Animation outtoLeft = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 1.0f,
Animation.RELATIVE_TO_SELF, 0.0f);
outtoLeft.setDuration(500);
outtoLeft.setInterpolator(new AccelerateInterpolator());
return outtoLeft;
}
then
set this action to your frame:
public void onLeftArrowClick(View v) {
frame.setAnimation(moveComingSoonToBottomAnim); // your Frame variable
animVariable.startNow();// your anime variable
frame.setVisibility(View.VISIBLE);
rightFrame.setVisibility(View.GONE); // hide your right text view
}

Related

ImageView clear animation

I have an animation in my code.
But I want when I click Button my ImageView return to original place(reset animation)
I have a method for that.
My code is :
private void returnToOriginalRotationState() {
RotateAnimation animation = new RotateAnimation(0.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setInterpolator(new LinearInterpolator());
animation.setDuration((long) 2*1000);
animation.setFillAfter(true);
animation.setFillEnabled(true);
imgHeade.startAnimation(animation);
}
It works as well
But
animation.setDuration((long) 2*1000);
not working !!!
try this for clear animation:
imgHeade.clearAnimation();

Custom Navigation slider

I'm trying to make a custom navigation drawer in android.
It should compromise of a spinner view for selecting city from the list, then city temperature and then name, email and contact no.
I'm able to make city option and edit text list for name, email etc. Now I can't insert temp details in it.
need help
Closing animation of your slider
public static void playcloseanimationofleftdrawer() {
TranslateAnimation translateAnimation = new TranslateAnimation(
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, -1.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
translateAnimation.setInterpolator(new DecelerateInterpolator(2.0f));
AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
AnimationSet animation = new AnimationSet(false);
animation.addAnimation(translateAnimation);
animation.addAnimation(alphaAnimation);
animation.setAnimationListener(new Animation.AnimationListener() {
#Override
public void onAnimationStart(Animation animation) {
// Do nothing
}
#Override
public void onAnimationRepeat(Animation animation) {
// Do nothing
}
#Override
public void onAnimationEnd(Animation animation) {
}
});
animation.setDuration(500);
leftdrawer.startAnimation(animation);
}
Opening animation of your slider
public static void playopenanimationleftdrawer() {
TranslateAnimation translateAnimation = new TranslateAnimation(
TranslateAnimation.RELATIVE_TO_SELF, -4.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f,
TranslateAnimation.RELATIVE_TO_SELF, 0.0f);
translateAnimation.setInterpolator(new DecelerateInterpolator(2.0f));
AlphaAnimation alphaAnimation = new AlphaAnimation(0.0f, 1.0f);
AnimationSet animation = new AnimationSet(false);
animation.addAnimation(translateAnimation);
animation.addAnimation(alphaAnimation);
animation.setDuration(1000);
animation.setFillAfter(true);
leftdrawer.startAnimation(animation);
}
Just think how you can achieve that!Anyway giving you how to do it.First make relative layout inside your layout,call that relative layout lets say left drawer.After which give that new created layout a color,basically you might want to give white color,ok next step is to give the height of relative layout
match_parent or fill_parent
and the width of your layout should be fixed size...or if you want your drawer to be from start of screen to end of screen you can still use above written code.So after all this all you have to do is to put a button above your created layout(most useful button is ToggleButton as it have 2 states to be pressed(on/off)) and that button will make your created layout to go either VISIBLE or INVISIBLE,so here you have custom sliding drawer where you can put any widget you like and put some translate animation onto it to make it fell real drawer.Good Luck

can I force an animation in android to take something else than float?

I am trying to move a view inside a layer, something like an Horizontal Scroll, I have done it with motion events and I need to add an animation. The view should follow the finger on the screen all the time and when it's released it should, from that position move to the edge of the screen. Now I managed to do all of this but I have problems with the animation coordinates since it takes on only float values and I need it to take 2 digit values after the 0.
Here is my animation attempt:
public static Animation inFromRightAnimation() {
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, temp/1000,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(500);
return inFromRight;
}
temp should be the value where the finger is and it's usually something between 100-300, so I divide it by 1000 to get 0.36 lets say but because the animation will accept temp only as float I get only 0.3. Any ideas how I can make it to get 0.36?
Try (float)temp/1000.0 instead.

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