I am animating two image views both having the width of the screen. As soon as the first image starts translating in the x direction right(moving off the screen) the second image appears at the far left of the screen filling the gap of the first image. They continue to move in a infinite cycle. It gives the impression of a rolling scenery.
Everything works perfectly except the line where two images meet. That line flicks. I synchronized the
translation of the images by setStartDelay() method. I also tried using AnimationListener. But that merging line of the two images always flicks.
How to solve this issue or what is the best way to do this animation?
Related
I'm building an app where I want to swipe images as though they were photos on a stack. In other words, if I swipe the top image I want it to animate moving in the direction of the swipe and have the next image underneath it visible the whole time. To accomplish this, I'm using a FrameLayout and two ImageView containers. I'm just alternating which one is on top. Meanwhile, as soon as a swipe occurs, the next image is loaded into the ImageView at the back using setBackground(drawable). My problem is that the ImageView at the back doesn't update it's image until I call bringToFront() on it, which means that as the top ImageView is animating, the image underneath is incorrect until the animation completes, at which point it abruptly changes to the correct image. I've tried calling invalidate() on the rear ImageView after setBackground(drawable) but this doesn't work. Anyone have any ideas on how I can get the image to update while it's behind?
UPDATE: Turns out I'm just not very on it today. I was updating the wrong ImageView and because the image loading was being done off the network, there was just enough lag to make me think it was happening after the animation completed.
Sounds to me like you wanna do something like an Image Slider.
There are great libraries existing for this purpose, this one for example:
https://github.com/daimajia/AndroidImageSlider
If you don't wanna use this, here are some tips:
Images on ImageViews are set with setImageDrawable(Drawable)
When your animation starts, set the new Image to your ImageView behind and slide the visible one away.
When the visible ImageViewhas slided away, set it's visibility to GONEand move it behind the second ImageView
Do this for every time a new image is loaded.
This should actually work.
You need a "ViewPager"
https://developer.android.com/training/animation/screen-slide.html
It has all the necessary handles to accommodate "N" number of images - also supports multiple swipe animations - default handlers - efficient memory management - prefetching - you are all in for a feast with this !!
Just make sure you get the "ImageView" in the layout of the "pages" you wish to develop on the "ViewPager".
We want to show in an Android app a list of images in the similar manner with many gallery apps: horizontal sliding by using a gesture to show the next/previous image.
Also the image viewer should support zoom/pinch (besides other features).
Images can came from a database or from a directory and can be as much as 200-300.
The question is: Which is the best way to implement the slide-show part from the environment described above?
Through animations of a two TImage? There exist a specialized component for this? By using Horizontal Scroll box?
Stick 10 TRectangle objects in a THorzScrollBox. It could be more or less than 10 depending on the memory that the device has. Align them all to alTop. Load the images for display in TRectangle.Fill.Bitmap.Bitmap.
When the user scrolls down and is near the bottom of the ten, move the top rectangle to the bottom of the chain and load the newest image from your list into the new bottom one.
When the user scrolls up and is near the top of the ten, move the bottom rectangle to the top of the chain and load the newest image from your list into the new top one.
The reason behind doing it this way is that TRectangle is a really light image display container and you are recycling the TRectangle objects instead of deleting and creating them all the time.
It is possible that you will experience a display pop when you move the next TRectangle object to the top of the chain or when you move it to the bottom of the chain. You will have to create code to take care of this either by setting the position on THorzScrollBox or decreasing and increasing the height of the TRectangle as it leaves or enters the view until it is full size.
If you have installed samples with your Delphi instalation then you can find several examples of how to do this in:
Samples\FireMonkey\Fireflow
Samples\FireMonkey\MetropolisUIFlipViewDemo
Maybe there are even more of them. I haven't checked every sample so far.
I have three different images and i want to write a code which will randomly select any of these images and display it at the top of the screen.
Then this image will move downwards and once it reaches the bottom of the screen the image will disappear from the screen.
Now this logic should be continued in the loop where these images will keep on appearing at the top and move towards the bottom of the screen.
I am unable to figure out a way for this. I am trying this on the Canvas.
Basically these three images are kind of Weapons (one is arrow, another is bomb and third one is missile). I want a continuous loop where these images will keep on occurring at the top of the screen and moves downwards and disappear once they reach the bottom.
Can anyone please help me with this?
Main idea is to display 2 square images and then upon button click they should shrink to nothing then display a new image from nothing and grow to normal size. (if possible I'd also like to add a rotation as it shrinks and grows)
I've followed http://developer.android.com/resources/tutorials/opengl/opengl-es20.html
but as I don't have access to an android device till tomorrow I have no way of testing it out right now so I'm hoping anybody might know of existing tutourials which covers anything like this.
I don't want any animation to occur during normal running and it should only occur during my click handler, ofc I still like the images to be displayed till the button clicked just not in motion.
I don't see where the problem is, it is just a simple game of scaling of your object model view.
When you want to scale down ---> you decrease the scaling factor toward zero
Change picture ---> Change binded texture (or change the texture coordinates if you have an atlas)
Scale up ---> increase the scaling factor toward 1.0
So I have multiple very long images (like 2000x100) that i want to have scrolling across the screen at different speeds. and my original solution is not working out. Originally, I placed them all in a HorizontalScrollView, and made a runnable that used setPadding to adjust the position of the ImageViews within the scrollView. This works, however, the background that is supposed to remain mostly stationary on the screen, shakes back and forth as you scroll, and lags behind the scroll location significantly. It's choppy and it looks bad.
Is there any other way that I can move images across the screen to achieve the desired effect?
(could I perhaps use a frame layout, and set an ontouchlistener? then how would you move the layout across the screen?)
I set up a layout so that the images protrude off of the right of the screen correctly, but I can't seem to move them off of the left of the screen (setpadding(-50,0,0,0) does not work)
Thanks in advance!
I solved this by using relative layouts within a frame layout. I set an ontouchlistener for the frame layout and used the scrollTo method for each image with a modifying coefficient. I had not previously noticed the scrollTo and scrollBy methods of the layout.