Android Layouy background image causing choppy animation - android

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?

Related

using animation in imageview while changing image

I have used the code here to animate changing image of an ImageView. But it converts the first image to a white screen and then fade the white screen into the final image (no matter if I use background for ImageView or not).
the same effect is appeared when using slide_out_right and slide_in_left.
Question:
How can I directly go from current Image to a new Image using a custom Animation?
I know that it is possible when using ImageSwitcher but I wanne do it in an ImageView
TransitionDrawable is not the solution because it is applicable only for fade. I wanna use translate or any custom animation.
thanks for any help
Edit:
I think I got the answere, but I am not sure if it an efficient solution:
the white screen is because I am animating the whole ImageView. when it goes out the display what appeared is the Layout background which is white.
To solve the problem, I used two ImageViews and copy the current Image to one and the new image to the another one. animation_in is applied to the imageview containing new image and animation_out to the other one.

How to remove the android Button Background margins?

I'm new to Android dev, I'm trying sth simple: I want to place a set of 3 buttons horizontally in a line, each with its own background PNG image. So I create a linear layout (horiz) and put three Button elements, each with a weight of 1, and set each button's Background property to some png file. The buttons' width/height is set to wrap_content.
But what I get is that the png does not cover the entire button horizontal area. Instead, the background image is scaled down and keeps some sort of margin from the button view outline as shown in the visual designer. This also shows up in the emu. I tried forcing 0 in the layout's padding/margin - nada.
any idea on how to actually get the background image of a button to cover the button's background??
tnx
I believe you would need to make a new 9-patch, as that small margin is saved into the button image itself.
Try negative values for the buttons layout_margin.

Android ViewFlipper, how to use it correctly? It is slow and laggy

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?).

Android ViewFlipper animation does not render background?

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.

android resize animation

Is there a way to apply a 'resize' animation as opposed to a scale animation in Android? When using the scale animation, the image or layout being resized is stretched out, this includes the border / stroke outline that is outlines the image. I have a box, with 2 lines around them, when the animation is applied the stroke appears to grow, this is likely due to the fact that the 'scale' animation is actually scaling the borders/strokes in addition to the drawable. Is there any way to have the box grow, without having the stroke/border/outline appear to grow as well? i.e. i just want to resize, but not necessarily 'rescale' the drawable. note, my drawable is defined in xml...
I would suggest removing the borders from the image and instead draw this border by wrapping your ImageView with a LinearLayout. Use some padding to create the borders and set the background color of your LinearLayout to apply the border appearance desired.
The default animation tools in Android do not provide a way to perform resize animations. Your best bet is to have a TimerTask that changes the dimensions of the view on the UI thread at specified time intervals.

Categories

Resources