温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

安卓动画移动放大淡化

发布时间:2020-08-03 18:28:43 来源:网络 阅读:222 作者:海大易小晨 栏目:开发技术
public class MainActivity extends Activity {

	Button button1, button2, button3, button4, button5,button6,button7;

	TranslateAnimation up_down;
	TranslateAnimation down_up;
	TranslateAnimation left_right;
	TranslateAnimation right_left;
	AlphaAnimation have_not;
	ScaleAnimation small_big;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		button1 = (Button) findViewById(R.id.button1);
		button2 = (Button) findViewById(R.id.button2);
		button3 = (Button) findViewById(R.id.button3);
		button4 = (Button) findViewById(R.id.button4);
		button5 = (Button) findViewById(R.id.button5);
		button6 = (Button) findViewById(R.id.button6);
		button7 = (Button) findViewById(R.id.button7);

		up_down = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
				Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
				-1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
		up_down.setDuration(500);

		down_up = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
				Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
				1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
		down_up.setDuration(500);

		left_right = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1.0f,
				Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
				0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
		left_right.setDuration(500);

		right_left = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1.0f,
				Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
				0.0f, Animation.RELATIVE_TO_SELF, 0.0f);
		right_left.setDuration(500);

		have_not = new AlphaAnimation(1, 0);
		have_not.setFillAfter(true);
		have_not.setDuration(500);

		small_big = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF,
				0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
		small_big.setDuration(500);

		button5.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				button1.startAnimation(up_down);
				button2.startAnimation(left_right);
				button3.startAnimation(right_left);
				button4.startAnimation(down_up);
				button6.startAnimation(small_big);
				button7.startAnimation(have_not);

			}
		});

	}
}


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI