Adding Chat Heads in Android
// Get window Manager object,
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
// Initialize floating icon,
ImageView chatHead = new ImageView(mContext);
chatHead.setImageResource(R.drawable.chatHeadIcon); //chat head Icon
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT);
// Set the position on the screen,
params.gravity = Gravity.TOP | Gravity.RIGHT;
params.x = 0;
params.y = 100;
windowManager.addView(chatHead, params);
Comments
Post a Comment