Android-在屏幕上连续浮动图像

时间:2015-05-06 05:58:36

标签: android android-animation translate-animation

我想在屏幕上连续移动这两个图像。它应该像屏幕上的气泡一样漂浮。我尝试了使用翻译动画和alpha动画的东西,但这不起作用它只是浮动图像几秒钟,但我想在整个屏幕区域连续移动/浮动图像。怎么做?如果有任何人有这个想法,请告诉我,这是我的代码,请检查:

setContentView(R.layout.activity_main);
LinearLayout l = (LinearLayout) findViewById(R.id.l);
AnimationSet set = new AnimationSet(true);

Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(1000);
// animation.setRepeatCount(10);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f,
                                   Animation.RELATIVE_TO_SELF,  0.0f, 
                                   Animation.RELATIVE_TO_SELF,  0.0f, 
                                   Animation.RELATIVE_TO_SELF, 10.0f);
animation.setDuration(1500);
set.addAnimation(animation);

LayoutAnimationController controller = new LayoutAnimationController(set, 0.25f);
l.setLayoutAnimation(controller);
controller.start();

0 个答案:

没有答案