标签:
把一个控件长期的添加到窗口上
private void showAddress(String address){ wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.height = WindowManager.LayoutParams.WRAP_CONTENT; params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; params.format = PixelFormat.TRANSLUCENT; params.type = WindowManager.LayoutParams.TYPE_TOAST; params.setTitle("Toast"); tv = new TextView(this); tv.setText(address); tv.setTextSize(30f); tv.setTextColor(Color.BLUE); wm.addView(tv, params); }
想移除的话用wm.removeView(tv);
标签:
原文地址:http://www.cnblogs.com/84126858jmz/p/5016863.html