码迷,mamicode.com
首页 > 移动开发 > 详细

android项目windowManager简单实用

时间:2015-12-03 17:10:04      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

把一个控件长期的添加到窗口上

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);

android项目windowManager简单实用

标签:

原文地址:http://www.cnblogs.com/84126858jmz/p/5016863.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!