Reputation: 1037
I have an image:
I am adding this image as a source to a custom ImageView:
public class TopCropImageView extends ImageView {
public TopCropImageView(Context context) {
super(context);
setScaleType(ScaleType.MATRIX);
}
public TopCropImageView(Context context, AttributeSet attrs) {
super(context, attrs);
setScaleType(ScaleType.MATRIX);
}
public TopCropImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
setScaleType(ScaleType.MATRIX);
}
@Override
protected boolean setFrame(int l, int t, int r, int b) {
Matrix matrix = getImageMatrix();
float scaleFactor = getWidth()
/ (float) getDrawable().getIntrinsicWidth();
matrix.setScale(scaleFactor, scaleFactor, 0, 0);
setImageMatrix(matrix);
return super.setFrame(l, t, r, b);
}
}
And then I am giving only 100dp height to this TopCropImageView in xml and the imageview looks like:
This is what I wanted.
The problem is that when I click the image, i want it to expand and thus become the first image. Like the banner expands.
I have done this with LayoutParams, but i want to animate it.
I have tried scaled animation but doing that, the smaller part of the image only expands.
I want the imageview to behave like a curtain and thus make the background image visible. Please Help.
Thanks
Upvotes: 2
Views: 380
Reputation: 2355
You need a ValueAnimator inside your custom image view. Have a look here http://developer.android.com/guide/topics/graphics/prop-animation.html#value-animator
Upvotes: 0