Android 4.4.2中动画和ImageView的行为

时间:2014-02-11 11:00:48

标签: android animation imageview android-animation android-4.4-kitkat

Android 4.4.2中的奇怪之处 - 问题

当我点击它时,我将setAnimation设置为ImageResource到ImageView。

((ImageView) v).setImageResource(R.drawable.set_animation);

好吧它不应该开始因为在Android 4.0中; 4.1; 4.2和4.3我必须致电

(AnimationDrawable)((ImageView) v).getDrawable().start(); 

因此,在设置ImageResource动画开始时,在Android 4.4.2中。

有人可以告诉为什么会发生这种情况,如何阻止动画启动?提前告诉你。

2 个答案:

答案 0 :(得分:2)

尝试将您的实施更改为此,看看您是否有更好的体验:

 // Load the ImageView that will host the animation and
 // set its background to our AnimationDrawable XML resource.
 ImageView img = (ImageView)findViewById(R.id.spinning_wheel_image);
 img.setBackgroundResource(R.drawable.spin_animation);

 // Get the background, which has been compiled to an AnimationDrawable object.
 AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();

 // Start the animation (looped playback by default).
 frameAnimation.start();

在此处找到:http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html

答案 1 :(得分:1)

您可以像这样调用stop():

select ...
from (SELECT SUM(iloscrec*ilosc/100) AS iloscsur, surowiec, Produkt
        FROM receptura
        JOIN produkcjadb ON(produkcjadb.Produkt = receptura.kolor)
       WHERE data_zakonczenia >= CURRENT_DATE
       GROUP BY surowiec
      ) t1 join (
      SELECT SUM(ilosccal) AS ilosc, material, jednostka
        FROM surowce
       WHERE magazyn='G' || magazyn='K' || magazyn='S' || magazyn='P' || magazyn='PROUT' || magazyn='W'  || magazyn='OR'
       GROUP BY material
      ) t2
      on t2.material = t1.surowiec