安卓动画移动放大淡化
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); } }); } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。