简单实用步骤:
1.新建anim文件夹,
2.在anim下新建xml文件,
3.在xml下编写自己需要动画。
简单例子:
给Imageview添加动画
public class MainActivity extends Activity {
private ImageView imv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imv=(ImageView) findViewById(R.id.imv);
//加载动画
Animation an= AnimationUtils.loadAnimation(this,R.anim.scale );
imv.setAnimation(an);
imv.setImageResource(R.drawable.bg6);
}
}
动画设置:
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="2000"
android:fromYDelta="100%p"
android:toYDelta="0" />
<alpha
android:duration="2000"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
原文地址:http://blog.csdn.net/u013425527/article/details/40583499