title: How do I use WindowManager to overlay an Activity?
body: <p>How can I have an activty overlay like the one used in Facebook Messenger using the <code>WindowManager</code>?</p>
  
  <blockquote>
    <p>This is what I want</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/qAtLe.jpg" alt="This is what I want"></p>
  
  <blockquote>
    <p>This is what I have so far</p>
  </blockquote>
  
  <p><img src="https://i.stack.imgur.com/ppEPl.png" alt="this is what I have so far."></p>
  
  <p>first widnow manger thats who have chatheads bubble</p>
  
  <pre><code> params = new WindowManager.LayoutParams(
              WindowManager.LayoutParams.MATCH_PARENT,
              WindowManager.LayoutParams.MATCH_PARENT,
  
              WindowManager.LayoutParams.TYPE_PHONE,
              WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
              PixelFormat.TRANSLUCENT);
  
  
      params.gravity = Gravity.TOP | Gravity.LEFT;
      params.x = 0;
      params.y = 100;
  </code></pre>
  
  <p>This is the code I have for my activity dialog</p>
  
  <pre><code>WindowManager.LayoutParams params = getWindow().getAttributes();
  
      params.alpha = 1.0f;    // lower than one makes it more transparent
      params.dimAmount = 0f;  // set it higher if you want to dim behind the window
      params.type = WindowManager.LayoutParams.TYPE_PHONE;
      params.flags = WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON|              WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
  
      params.x = 0;
      params.y = (int) (height - dpToPx(this,40));
  
      getWindow().setAttributes(params);
  </code></pre>
  
  <p>This is the activity in my manifest:</p>
  
  <pre><code> &lt;activity
          android:name=".activity.popup"
          android:configChanges="orientation|screenSize"
          android:excludeFromRecents="true"
          android:label="@string/app_name"
          android:launchMode="singleInstance"
          android:taskAffinity=""
          android:theme="@style/Theme.FloatingWindow.Popup"
          android:windowSoftInputMode="adjustPan|adjustResize"
          tools:ignore="ExportedActivity" &gt;
      &lt;/activity&gt;
  </code></pre>
  
  <p>Here is the <code>@style/Theme.FloatingWindow.Popup</code> style in style file I made:</p>
  
  <pre><code> &lt;style name="Theme.FloatingWindow.Popup" parent="@style/Theme.AppCompat.Light" &gt;  
      &lt;item name="windowNoTitle"&gt;true&lt;/item&gt;
      &lt;item name="windowActionBar"&gt;false&lt;/item&gt;
      &lt;item name="android:windowIsFloating"&gt;false&lt;/item&gt;
      &lt;item name="android:windowSoftInputMode"&gt;adjustResize&lt;/item&gt;
      &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt;
      &lt;item name="android:colorBackgroundCacheHint"&gt;@null&lt;/item&gt;
      &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt;
      &lt;item name="android:windowActionModeOverlay"&gt;true&lt;/item&gt;
      &lt;item name="android:windowIsTranslucent"&gt;true&lt;/item&gt;
      &lt;item name="android:windowFrame"&gt;@null&lt;/item&gt;
      &lt;item name="android:windowCloseOnTouchOutside"&gt;false&lt;/item&gt;
      &lt;item name="android:windowAnimationStyle"&gt;@null&lt;/item&gt;
      &lt;item name="android:backgroundDimEnabled"&gt;false&lt;/item&gt;
  
  &lt;/style&gt;
  </code></pre>