0
在我的應用我有一個按鈕,通過這個java代碼下面的動畫設置爲它停止動畫時,按下按鈕
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/bounce_interpolator" >
<scale
android:duration="2000"
android:fromXScale="0.9"
android:toXScale="1.0"
android:fromYScale="0.9"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
/>
</set>
:當按鈕被集中
myAnim = AnimationUtils.loadAnimation(this, R.anim.anim_button);
Button myButton = (Button) findViewById(R.id.run_button);
myButton.setAnimation(myAnim);
myButton.startAnimation(myAnim);
現在我想(或按下)動畫停止,我的按鈕大小減小(例如從寬度120dp到寬度100dp) 我該怎麼做?也是我在Java代碼中設置下面的XML我的按鈕
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_button_focuses"
android:state_pressed="true"
android:state_enabled="true"/>
<item android:drawable="@drawable/ic_button_focuses"
android:state_focused="true"
android:state_enabled="true"/>
<item android:drawable="@drawable/ic_button"
/>
</selector>
tnx哥們,設置在我的按鈕上的動畫就像一顆跳動的心。我想停止跳動,當我的手指觸摸按鈕(我的手指仍然在按鈕上) – farshid83
請參閱這裏http://stackoverflow.com/questions/4112599/how-to-stop-an-animation-cancel-does-不工作 – Raju
是否有任何偵聽器方法專注於按鈕? – farshid83