Animated Icon for ActionItem

You’re on the right track. Here is how the GitHub Gaug.es app will be implementing it. First they define an animation XML: <rotate xmlns:android=”http://schemas.android.com/apk/res/android” android:fromDegrees=”0″ android:toDegrees=”360″ android:pivotX=”50%” android:pivotY=”50%” android:duration=”1000″ android:interpolator=”@android:anim/linear_interpolator” /> Now define a layout for the action view: <ImageView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:src=”https://stackoverflow.com/questions/9731602/@drawable/ic_action_refresh” style=”@style/Widget.Sherlock.ActionButton” /> All we need to do is enable this view … Read more

Android adding simple animations while setvisibility(view.Gone)

You can do two things to add animations, first you can let android animate layout changes for you. That way every time you change something in the layout like changing view visibility or view positions android will automatically create fade/transition animations. To use that set android:animateLayoutChanges=”true” on the root node in your layout. Your second … Read more

How do android screen coordinates work?

This image presents both orientation(Landscape/Portrait) To get MaxX and MaxY, read on. For Android device screen coordinates, below concept will work. Display mdisp = getWindowManager().getDefaultDisplay(); Point mdispSize = new Point(); mdisp.getSize(mdispSize); int maxX = mdispSize.x; int maxY = mdispSize.y; EDIT:- ** **for devices supporting android api level older than 13. Can use below code. Display … Read more

android animation is not finished in onAnimationEnd

Here is the actual bug related to this issue http://code.google.com/p/android-misc-widgets/issues/detail?id=8 This basically states that the onAnimationEnd method doesn’t really work well when an AnimationListener is attached to an Animation The workaround is to listen for the animation events in the view to which you were applying the animation to For example if initially you were … Read more

Android – zoom in/out RelativeLayout with spread/pinch

So I created a subclass of RelativeLayout as described in the above mentioned topics. It looks like this: public class ZoomableRelativeLayout extends RelativeLayout { float mScaleFactor = 1; float mPivotX; float mPivotY; public ZoomableRelativeLayout(Context context) { super(context); // TODO Auto-generated constructor stub } public ZoomableRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor … Read more

How to maintain multi layers of ImageViews and keep their aspect ratio based on the largest one?

this is a class that displays an image with additional layers: import java.util.ArrayList; import java.util.Iterator; import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.util.AttributeSet; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.Transformation; import android.widget.ImageView; public class LayeredImageView extends … Read more

Show and hide a View with a slide up/down animation

With the new animation API that was introduced in Android 3.0 (Honeycomb) it is very simple to create such animations. Sliding a View down by a distance: view.animate().translationY(distance); You can later slide the View back to its original position like this: view.animate().translationY(0); You can also easily combine multiple animations. The following animation will slide a … Read more