2

我是android开发新手。我想在屏幕上有一个连续移动的按钮。当它接触到侧面时,它应该会弹回来。点击时会打开活动。我该怎么做呢?任何有用的链接?想法?谢谢!

4

1 回答 1

1

对于移动按钮,您需要使用动画这里是它的片段

TranslateAnimation  mAnimation = new TranslateAnimation(
                            TranslateAnimation.RELATIVE_TO_PARENT, 1f,
                            TranslateAnimation.RELATIVE_TO_PARENT, -1.2f,
                            TranslateAnimation.ABSOLUTE, 0f,
                            TranslateAnimation.ABSOLUTE, 0f
                           );
                   mAnimation.setDuration(15000);
                   mAnimation.setRepeatCount(-1);
                   mAnimation.setRepeatMode(Animation.INFINITE);
                   mAnimation.setInterpolator(new LinearInterpolator());
                   mAnimation.setFillAfter(true);

                    LinearLayout alertlayout = (LinearLayout) findViewById(R.id.alertll);
                    alertlayout.startAnimation(mAnimation);

并开启一项新活动

Intent intent = new Intent(YourActivity.this,NewActivity.class);
StartActivity(intent);
于 2013-06-26T05:13:58.997 回答