Dialog dialog = new Dialog(this.getApplicationContext()); | |
TextView textView = new TextView(this); | |
textView.setText("this is toast!"); | |
dialog.setContentView(textView); | |
dialog.getWindow().setType(LayoutParams.TYPE_SYSTEM_ERROR); | |
dialog.show(); |
mFloatingButton = new Button(this); | |
mFloatingButton.setText("click me"); | |
mLayoutParams = new WindowManager.LayoutParams( | |
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0, 0, | |
PixelFormat.TRANSPARENT); | |
mLayoutParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL | |
| LayoutParams.FLAG_NOT_FOCUSABLE | |
| LayoutParams.FLAG_SHOW_WHEN_LOCKED; | |
mLayoutParams.type = LayoutParams.TYPE_SYSTEM_ERROR; | |
mLayoutParams.gravity = Gravity.LEFT | Gravity.TOP; | |
mLayoutParams.x = 100; | |
mLayoutParams.y = 300; | |
mFloatingButton.setOnTouchListener(this); | |
mWindowManager.addView(mFloatingButton, mLayoutParams); |