ITeye博客

类似360的桌面小图标

AndroidLL · 2013-05-30 13:58 · Android · 移动开发 · Markdown

其实这个实现很简单!就是在WindowManager中添加一个显示view

 

floatView = new FloatView(getApplicationContext());
		floatView.setOnClickListener(this);
		floatView.setImageResource(R.drawable.ic_launcher); 
		windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
		windowManagerParams = ((FloatApplication) getApplication()).getWindowParams();
		windowManagerParams.type = LayoutParams.TYPE_PHONE; 
		windowManagerParams.format = PixelFormat.RGBA_8888; 
		windowManagerParams.flags = LayoutParams.FLAG_NOT_TOUCH_MODAL
				| LayoutParams.FLAG_NOT_FOCUSABLE;
		
		windowManagerParams.gravity = Gravity.LEFT | Gravity.TOP; 
		windowManagerParams.x = 0;
		windowManagerParams.y = 0;
		windowManagerParams.width = LayoutParams.WRAP_CONTENT;
		windowManagerParams.height = LayoutParams.WRAP_CONTENT;
		windowManager.addView(floatView, windowManagerParams);

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。