0
當我嘗試動畫自定義視圖(在java代碼中創建)時,沒有效果,動畫無法啓動。這是我如何做到這一點:動畫定製視圖類
final Animation animation = AnimationUtils.loadAnimation(this, R.anim.animation);
final CustomView background = new CustomView(this);
background.setBackgroundResource(R.drawable.bg);
background.startAnimation(animation);
CustomView擴展ImageView。
此代碼不啓動動畫,我也嘗試ImageView,也不起作用。
只有當我從findViewById(id)獲得View時,動畫纔有效。
這裏是動畫代碼:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false"
>
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="1000"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="1.0"
android:startOffset="1000"
android:duration="6000"
/>
<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:startOffset="7000"
android:duration="1000"
/>
</set>
你可以發佈動畫的xml代碼嗎? – 2010-07-16 23:11:12
android:shareInterpolator =「false」屬性是無用的,但我從另一個動畫應對這個文件,並忘記切割它。 – Fisher 2010-07-17 00:23:03