Siddharth
Siddharth

Reputation: 9584

Trying to Animate a ImageView, does not work

Animation file to get the zoom in the view from top left to full screen

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<scale
    android:duration="800"
    android:fromXScale=".1"
    android:fromYScale=".1"
    android:pivotX="100%"
    android:pivotY="0%"
    android:toXScale="1.0"
    android:toYScale="1.0"/>
</set>

In the onCreate I have

newHintAnimation = AnimationUtils.loadAnimation(this,
                R.anim.newhintzoomin);
newHintAnimation.setAnimationListener(this) ;

In my onClick

try {
    hintBitmap = BitmapFactory.decodeStream(this.getApplicationContext()                    .getAssets().open("logos/"+question.getShintFileName()));
    } catch (IOException e) {
    hintBitmap = null ;
    e.printStackTrace();

hintImage.setVisibility(View.VISIBLE) ;
hintImage.setImageBitmap(hintBitmap);
newHintAnimation.reset() ;
hintImage.startAnimation(newHintAnimation) ;

My layout xml has the following

<ImageView
    android:id="@+id/hintImage"
    android:layout_width="60dip"
    android:layout_height="60dip"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/question_header_layout"
    android:layout_marginLeft="10dip"
    android:layout_marginTop="10dip"
    android:visibility="visible" />

I checked, I am not get a null on the bitmap. If run the same code in a Activity using overridePendingTransition(R.anim.newhintzoomin, 0) ; it works.

Upvotes: 0

Views: 227

Answers (1)

Ushal Naidoo
Ushal Naidoo

Reputation: 2744

Please try this is :

Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.newhintzoomin);
hintImage.startAnimation(newHintAnimation);

Let me know if it works :) Good Luck

Upvotes: 1

Related Questions