2014-11-29 3 views
0

내 레이아웃에 ImageView가 있습니다.ImageResource에서만 ImageView 애니메이션을 추가하는 방법

ImageButton ib = (ImageButton) findViewById(R.id.btn1); 

ib.setImageResource(R.drawable.blue_3); 

I want to have an animation only R.drawable.blue_3 icon left to right. 
+0

확인이 추가를 http://www.javasrilankansupport.com/2013/06/how-to-move-an-image-from-left-to-right-and-right-to-left-in-android.html –

+0

이것은 복용량입니다. 그랬다. 애니메이션 ImageButton을 시작했지만 imageResource를 애니메이션화하지 않을 것입니다. –

답변

0
try this its work for me....! 
make a folder in resource and name it anim and place this xml file 

(참고 : 당신은 당신이 그것을 편집 할 단일 이동하려면이 샘플 XML 파일입니다)

move.xml 

    <?xml version="1.0" encoding="utf-8"?> 
    <set xmlns:android="http://schemas.android.com/apk/res/android" 
     android:interpolator="@android:anim/accelerate_interpolator" > 

    <translate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:fromXDelta="-75%p" 
    android:toXDelta="75%p" 
    android:duration="2000" > 

    </translate> 

    <translate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:startOffset="800" 
    android:fromXDelta="75%p" 
    android:toXDelta="-75%p" 
    android:duration="2000" > 

    </translate> 
    </set> 

마지막으로 코드

Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), 
      R.anim.move); 
    Image.startAnimation(animation); 
+0

이것은 애니메이션 ImageButton을 시작했기 때문에 dosent 작업이지만 imageResource를 애니메이션화하지 않을 것입니다. –

관련 문제