[android-developers] Re: Question About animation
thanks On Jun 30, 11:02 am, Romain Guy romain...@android.com wrote: You simply need to use setFillAfter(true). On Wed, Jun 30, 2010 at 12:59 AM, zohar lerman lirazo...@gmail.com 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
[android-developers] Re: Question about animation
Thanks for your answer Daniel. I had some difficulties to understand but finally, it works ! Thanks a lot. The key point is to display the final result then make an animation that start from a negative position to 0. In my case, it works without having to use post ... Mike daniel.benedykt a écrit : Hi Mike Actually I just got the solution :) I was having this problem for a couple of days but just solved it. Here is the solution: When you want to animate from left to write do this: absoluteLayout.post(new SwapViewsDifferent()); then you have a inner class: private final class SwapViewsDifferent implements Runnable { public void run() { //first it scrolls, so android see the screen. absoluteLayout.scrollBy(screenWidth * -1, 0); //then the *animation* a little different from yours. compare the values *Animation **animation* = new TranslateAnimation(*Animation*.ABSOLUTE, -screenWidth, *Animation*.ABSOLUTE, 0, *Animation*.ABSOLUTE, 0, *Animation*.ABSOLUTE, 0); *animation*.setDuration(500); *animation*.setFillAfter(false); absoluteLayout.startAnimation(*animation*); } }; Hope this helps... Daniel Mike Baroukh a écrit : 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 -~--~~~~--~~--~--~---
[android-developers] Re: Question about animation
Hi Mike, I am having the same issue here. I try a lot of things and nothing worked. Does anyone have the answer to this? Thanks Daniel On Apr 16, 11:34 pm, Mike Baroukh m...@baroukh.com wrote: 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 ... MbaFlipper.java 3KViewDownload --~--~-~--~~~---~--~~ 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] Re: Question about animation
Hi Mike Actually I just got the solution :) I was having this problem for a couple of days but just solved it. Here is the solution: When you want to animate from left to write do this: absoluteLayout.post(new SwapViewsDifferent()); then you have a inner class: private final class SwapViewsDifferent implements Runnable { public void run() { //first it scrolls, so android see the screen. absoluteLayout.scrollBy(screenWidth * -1, 0); //then the animation a little different from yours. compare the values Animation animation = new TranslateAnimation(Animation.ABSOLUTE, -screenWidth, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0, Animation.ABSOLUTE, 0); animation.setDuration(500); animation.setFillAfter(false); absoluteLayout.startAnimation(animation); } }; Hope this helps... Daniel On Apr 18, 12:18 pm, daniel.benedykt daniel.bened...@gmail.com wrote: Hi Mike, I am having the same issue here. I try a lot of things and nothing worked. Does anyone have the answer to this? Thanks Daniel On Apr 16, 11:34 pm, Mike Baroukh m...@baroukh.com wrote: 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 ... MbaFlipper.java 3KViewDownload --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---