文件名称:仿QQ气泡拖动删除
文件大小:27.11MB
文件格式:RAR
更新时间:2020-10-15 15:29:25
QQ气泡
private RelativeLayout root; private BounceCircle messageCount; private BounceCircle contactCount; private ImageView messageIcon; private ImageView contactIcon; private int radius = 40; // 圆形半径 private boolean init = true; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); root = (RelativeLayout) findViewById(R.id.activity_main); messageIcon = (ImageView) findViewById(R.id.message_icon); contactIcon = (ImageView) findViewById(R.id.contact_icon); } @Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); // 只需执行一次,在onWindowFocusChanged方法中才能获取到控件在屏幕中的坐标 if (init) { init =false; int[] position = new int[2]; messageIcon.getLocationOnScreen(position); messageCount = new BounceCircle(this, radius, position[0] + messageIcon.getWidth(), (position[1] - Util.getTopBarHeight(this))); messageCount.setNumber("20"); messageCount.setFinishListener(new BounceCircle.FinishListener() { @Override public void onFinish() { Toast.makeText(MainActivity.this, "message count dismiss", Toast.LENGTH_LONG).show(); } }); root.addView(messageCount); contactIcon.getLocationOnScreen(position); contactCount = new BounceCircle(this, radius, position[0] + contactIcon.getWidth(), (position[1] - Util.getTopBarHeight(this))); contactCount.setNumber("30"); contactCount.setFinishListener(new BounceCircle.FinishListener() { @Override public void onFinish() { Toast.makeText(MainActivity.this, "contract count dismiss", Toast.LENGTH_LONG).show(); } }); root.addView(contactCount); } }