I'm using a ViewFlipper with two ListViews. When setting a background drawable on the ViewFlipper, the animation performed when "flipping" only renders the foreground, and background is black! When animation is done, the background appears.
Is there a known problem with animating the background "layer" of a view?
Also, the animation performance/frame rate on my HTC Hero decreases significantly when adding the background.
Any ideas or solutions? Thanks!
/Morten
I have the same problem and I found the following workaround. You have to set the background on the view being animated, not on the flipper. So for consistency, this would mean you have to set the same background on all the top level views contained in your flipper.
Related
I have LinearLayout with background property set to drawable resource and with in that layout I have 3 buttons with custom font and also background property set to drawable resource. On click of the button I have set layout animation on buttons via anim resource. With the main background on animation is somehow choppy, jerky, not smooth but when I delete background image the animation is very smooth and stable. In the hierarchy view I noticed that layout with background image has drawing time about 17 ms. Do anyone had this kind of issue and is there a way to make it smooth or another way around it?
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.
I'm attempting to fade between two background images on my Droid, but the animation seems to get 5fps if not less. Is there any method I can use other than fading in\out a couple image views that would be smoother?
You can set your background to be defined by a TransitionDrawable. Used it to develop a nice splash screen that fades in and didn't have any issues.
I'm not exactly sure what you want to do, but if you want to change from one screen to the other within the same app you should use the ViewFlipper.
View Flipper on Android Developer site
This will allow to smoothly change from one screen to the other (much like the iPhone way).
If it is about the actual Android background i can't help you. Sorry.
How can I use a ViewFlipper correctly?
A have a layout file, with a ViewFlipper. I included 7 layouts in there.
Using this code:
mFlipper = (ViewFlipper) ((Activity) mycontext).findViewById(R.id.flipper);
mFlipper.setInAnimation(AnimationUtils.loadAnimation(mycontext, R.anim.slide_left_in));
mFlipper.setOutAnimation(AnimationUtils.loadAnimation(mycontext, R.anim.slide_left_out));
mFlipper.setDrawingCacheEnabled(true);
and then:
mFlipper.setDisplayedChild(viewID);
but it is very slow, and laggy. sometimes it runs fast, but more time it is laggy and slow. why?
update: all of my layout's background picture is a big texture background with FILL_PARENT and transparent png.
Probably because
all of my layout's background picture is a big texture background with FILL_PARENT and transparent png.
Try to remove that background image from all those inner layouts and set it to the root one (ViewFlipper?).
I have a ViewFlipper with two ImageView widgets. I have set the in and out animation as android.R.anim.slide_in_left and android.R.anim.slide_out_right
Now when the two ImageViews have two different drawables, then the animation is sleek and smooth. But when I set the both the ImageViews to the same Drawable, the screen flickers. Why is this happening and how do I prevent it?
I think you might want to use Drawable.mutate() to prevent the drawable from being reused. :-)