我想动态地在我的应用中启用动画,就像我们手动设置>显示>动画>所有动画一样。
我尝试了附加代码,但无济于事,
Settings.System.putInt(getContentResolver(), Settings.System.WINDOW_ANIMATION_SCALE, 1);
Settings.System.putInt(getContentResolver(), Settings.System.TRANSITION_ANIMATION_SCALE, 1);
请帮忙
姆兰
答案 0 :(得分:0)
我认为。你可以为你的应用程序执行此操作。但是如果你将它用于你的设备意味着你可以阅读标志。如果它被禁用你可以打开设置面板打开以启用它用户。
答案 1 :(得分:0)
//声明动画
动画animationSlideInLeft,animationSlideOutRight;
//现在我们正在给图像视图动画
image1 = (ImageView)findViewById(R.id.image1);
image2 = (ImageView)findViewById(R.id.image2);
image3 = (ImageView)findViewById(R.id.image3);
animationSlideInLeft = AnimationUtils.loadAnimation(this,
android.R.anim.slide_in_left);
animationSlideOutRight = AnimationUtils.loadAnimation(this,
android.R.anim.slide_out_right);
animationSlideInLeft.setDuration(1000);
animationSlideOutRight.setDuration(1000);
animationSlideInLeft.setAnimationListener(animationSlideInLeftListener);
animationSlideOutRight.setAnimationListener(animationSlideOutRightListener);
curSlidingImage = image1;
image1.startAnimation(animationSlideInLeft);
image1.setVisibility(View.VISIBLE);
//创建动画监听器
AnimationListener animationSlideInLeftListener
= new AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
// TODO Auto-generated method stub
if(curSlidingImage == image1){
image1.startAnimation(animationSlideOutRight);
}else if(curSlidingImage == image2){
image2.startAnimation(animationSlideOutRight);
}else if(curSlidingImage == image3){
image3.startAnimation(animationSlideOutRight);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}};
//并且paus清除监听器
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
image1.clearAnimation();
image2.clearAnimation();
image3.clearAnimation();
}
2.通过将xml添加到res / anim /文件夹
,可以执行此操作