[android-developers] Question about animation

2009-04-17 Thread Mike Baroukh
Hi.

Hi have an absolute layout with pictures.
Only 2 pictures are show simultaneously. Others are on the layout, but 
out of view.

I wan't on user click to show others picture.
For this, I do an animation to translate the layer.

For translation from right to left, it works correctly : an other 
picture come from right progressively while another exit on left side.

But, for translation from left to right, it don't work : the right 
picture exits correctly on right side, but left picture only appear on 
left side at the end of the animation.
while translating, an empty space appear on left until the end of 
translation.

For translating, I make my own animation (not taken from XML because it 
depends on image size) :

scrollLeft = new TranslateAnimation(0, -(pictoWidth+hspace), 0, 0);
scrollLeft.setDuration(300);
scrollLeft.setAnimationListener(this);
scrollRight = new TranslateAnimation(0, (pictoWidth+hspace), 0, 0);
scrollRight.setDuration(300);
scrollRight.setAnimationListener(this);

then, for translating, I do :
layout.startAnimation(scrollRight);

(I join the widget source in case somebody is interesting on doing the 
same thing ...)


Does somebody have any idea how tohave the same effect on left to right 
scroll than right to left ?

Thanks in advance.

Mike

PS: I can't use filpper because I have to picture visible at the same 
time and only one disappear at a time.
It ould be possible but more complicated I thing ...




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---

package mba.android.widgets;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.view.animation.Animation.AnimationListener;
import android.widget.AbsoluteLayout;
import android.widget.FrameLayout;
import android.widget.ImageButton;

import com.fnacspectacles.android.R;

public class MbaFlipper extends FrameLayout implements AnimationListener {
	
	private ImageButton[] buttons = null;
	private AbsoluteLayout layout = null;
	
	private Animation scrollLeft, scrollRight;
	
	private boolean wasNext = false;

	public MbaFlipper(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public MbaFlipper(Context context) {
		super(context);
		init();
	}
	
	public int getNbManifs() {
		return 8;
	}

	private int pictoWidth=65, pictoHeight=80, hspace = 20, border = 1, vspace = 3, offset = hspace / 2;

	/** 
	 * Appelé au début pour initialiser les vues.
	 * Ensuite, il faudra appeler update avec les infos spécifiques à la manif.
	 */
	private void init() {

		layout = new AbsoluteLayout(getContext());
		LayoutParams paramsLayout = new LayoutParams(getNbManifs()*(pictoWidth+hspace+2*border), LayoutParams.FILL_PARENT);
		addView(layout, paramsLayout);
		layout.setPadding(-1 * (pictoWidth+hspace+2*border), 0, 0, 0);
		
		buttons = new ImageButton[getNbManifs()];
		for (int i=0; i0; i--) {
buttons[i]=buttons[i-1];
			}
			buttons[0]=b;
		}
		for (int i=0; i

[android-developers] Question About animation

2010-06-30 Thread zohar lerman
Hi,

I want to move a view from location (x,y) to (x1,y1).
What is the best way to do it?
I tried using the following code but it cannot stay at the last point
(x1,y1),it always translate back:
TranslateAnimation anim = 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);

anim.setDuration(100);
anim.setInterpolator(new LinearInterpolator());
this.startAnimation(anim);

any suggestions?

thanks
Z

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Question about animation

2012-01-24 Thread Daniel Rindt
Hello,

i would animate a VideoView what scales up and switch then to fullscreen. 
My code looks like:

final VideoView videoView = (VideoView) findViewById(R.id.video_view);
final ObjectAnimator x = ObjectAnimator.ofFloat(this, "x", 0);
x.setTarget(videoView);
final ObjectAnimator y = ObjectAnimator.ofFloat(this, "y", 0);
y.setTarget(videoView);
final ObjectAnimator scaleX = ObjectAnimator.ofFloat(this, "scaleX", 2);
scaleX.setTarget(videoView);
final ObjectAnimator scaleY = ObjectAnimator.ofFloat(this, "scaleY", 2);
scaleY.setTarget(videoView);
final AnimatorSet set = new AnimatorSet();
set.setInterpolator(new LinearInterpolator());
set.setDuration(1000);
set.playTogether(x, y, scaleX, scaleY);

Unfortunately nothing happens. I am happy to read suggestions.

Thanks in advance
Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Question About animation

2010-06-30 Thread Romain Guy
You simply need to use setFillAfter(true).

On Wed, Jun 30, 2010 at 12:59 AM, zohar lerman  wrote:
> Hi,
>
> I want to move a view from location (x,y) to (x1,y1).
> What is the best way to do it?
> I tried using the following code but it cannot stay at the last point
> (x1,y1),it always translate back:
> TranslateAnimation anim = 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);
>
> anim.setDuration(100);
> anim.setInterpolator(new LinearInterpolator());
> this.startAnimation(anim);
>
> any suggestions?
>
> thanks
> Z
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Question About animation

2010-06-30 Thread Mark Murphy
On Wed, Jun 30, 2010 at 4:02 AM, Romain Guy  wrote:
> You simply need to use setFillAfter(true).

That only works if the widget is non-interactive. Otherwise,
setFillAfter() moves the pixels, but the "hot spots" for interaction
remain at the old location.

For interactive widgets, you should set up an AnimationListener, and
when the animation ends, modify the layout to have the widget reside
at your desired new location.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Question about animation

2012-01-24 Thread Mark Murphy
I doubt that will work, as VideoView is backed by a SurfaceView, which
doesn't play by the same rules.

On Android 4.0, you could try replacing the VideoView with a
MediaPlayer and a TextureView. TextureView can be animated, IIRC.

On Tue, Jan 24, 2012 at 7:27 AM, Daniel Rindt
 wrote:
> Hello,
>
> i would animate a VideoView what scales up and switch then to fullscreen. My
> code looks like:
>
> final VideoView videoView = (VideoView) findViewById(R.id.video_view);
> final ObjectAnimator x = ObjectAnimator.ofFloat(this, "x", 0);
> x.setTarget(videoView);
> final ObjectAnimator y = ObjectAnimator.ofFloat(this, "y", 0);
> y.setTarget(videoView);
> final ObjectAnimator scaleX = ObjectAnimator.ofFloat(this, "scaleX", 2);
> scaleX.setTarget(videoView);
> final ObjectAnimator scaleY = ObjectAnimator.ofFloat(this, "scaleY", 2);
> scaleY.setTarget(videoView);
> final AnimatorSet set = new AnimatorSet();
> set.setInterpolator(new LinearInterpolator());
> set.setDuration(1000);
> set.playTogether(x, y, scaleX, scaleY);
>
> Unfortunately nothing happens. I am happy to read suggestions.
>
> Thanks in advance
> Daniel
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in DC: http://marakana.com/training/android/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Question about animation

2012-01-24 Thread Daniel Rindt
Thanks for your quick answer,

i have API Level 11 available for the application, so the compatibility 
package may help here? 
Another idea is to render one frame of the video in a hidden fullscreen 
element, then shrink it down and animate it. I think poeple can neglect 
that the video is not playing in the zoom animation.

Thanks for all input.
Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Question about animation

2012-01-24 Thread Mark Murphy
On Tue, Jan 24, 2012 at 9:43 AM, Daniel Rindt
 wrote:
> i have API Level 11 available for the application, so the compatibility
> package may help here?

No, sorry.

> Another idea is to render one frame of the video in a hidden fullscreen
> element, then shrink it down and animate it. I think poeple can neglect that
> the video is not playing in the zoom animation.

That seems reasonable.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in DC: http://marakana.com/training/android/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en