Android编程实现仿iphone抖动效果的方法(附源码下载)

2019-12-10 19:52:50于海丽
  • private static final float DEGREE_1 = -2.0f;  private static final float DEGREE_2 = 2.0f; 
  • private static final float DEGREE_3 = -1.5f;  private static final float DEGREE_4 = 1.5f; 
  • private static final int ANIMATION_DURATION = 80;  private int mCount = 0; 
  • float mDensity;  /** Called when the activity is first created. */ 
  • @Override  public void onCreate(Bundle savedInstanceState) { 
  • super.onCreate(savedInstanceState);  requestWindowFeature(Window.FEATURE_NO_TITLE); 
  • setContentView(R.layout.main);  DisplayMetrics dm = new DisplayMetrics(); 
  • getWindowManager().getDefaultDisplay().getMetrics(dm);  if (dm != null) { 
  • mDensity = dm.density;  } 
  • mtv0 = (TextView) findViewById(R.id.tv0);  mtv0.setOnClickListener(this); 
  • mtv1 = (TextView) findViewById(R.id.tv1);  mtv1.setOnClickListener(this); 
  • mtv2 = (TextView) findViewById(R.id.tv2);  mtv2.setOnClickListener(this); 
  • mtv3 = (TextView) findViewById(R.id.tv3);  mtv3.setOnClickListener(this); 
  • mtv4 = (TextView) findViewById(R.id.tv4);  mtv4.setOnClickListener(this); 
  • mtv5 = (TextView) findViewById(R.id.tv5);  mtv5.setOnClickListener(this); 
  • mtv6 = (TextView) findViewById(R.id.tv6);  mtv6.setOnClickListener(this); 
  • mtv7 = (TextView) findViewById(R.id.tv7);  mtv7.setOnClickListener(this); 
  • mtv8 = (TextView) findViewById(R.id.tv8);  mtv8.setOnClickListener(this); 
  • mtv9 = (TextView) findViewById(R.id.tv9);  mtv9.setOnClickListener(this); 
  • mtv10 = (TextView) findViewById(R.id.tv10);  mtv10.setOnClickListener(this); 
  • mtv11 = (TextView) findViewById(R.id.tv11);  mtv11.setOnClickListener(this); 
  • mtv12 = (TextView) findViewById(R.id.tv12);  mtv12.setOnClickListener(this); 
  • mtv13 = (TextView) findViewById(R.id.tv13);  mtv13.setOnClickListener(this);