title: Transparent Overlay in android
body: <p>I am trying to create a transparent overlay, should work on top of other application window also using code below.
  Problems are:<br>
  1) it doesn't work at the top of other application window.<br>
  2) background color is not transparent.</p>
  
  <p>java code:</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //-----
      final WindowManager.LayoutParams window_params=getWindow().getAttributes();
     // window_params.screenBrightness=1f;
      window_params.format = PixelFormat.TRANSPARENT;
      window_params.type=2006;
      getWindow().setAttributes(window_params); 
      //------
      view = new MyView(this);    //MyView view = new MyView(this);
      view.setBackgroundColor(Color.TRANSPARENT);
      view.changeSomethingInWindow(); // keep an eye on this method
      setContentView(R.layout.main);  //setContentView(view); //setContentView(view ,new LayoutParams(200,400));
  }
  public class MyView extends View{
  
      public MyView(Context context) {
          super(context);
      }
  
  
      public void changeSomethingInWindow(){
          // get a reference of the activity
          Activity parent = (Activity)getContext();
  
          Window window = parent.getWindow();
          window.getWindowManager();
          window.setLayout(300, 400);     //window.setLayout(getHeight()/2, getWidth()/2);
          window.setFormat(PixelFormat.TRANSPARENT);
          //window = new Window(this, R.style.Theme_Transparent);
        //  window.setBackgroundDrawableResource(getWindowVisibility());
          window.setFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                  WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); 
          window.getWindowStyle();
          window.getDecorView();
  
  
      }
  }   
  </code></pre>
  
  <p>style.xml: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;    &lt;resources&gt;
  &lt;style name="Theme.Transparent" parent="android:Theme"&gt;
      &lt;item name="android:windowIsTranslucent"&gt;true&lt;/item&gt;
      &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt;
      &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt;
      &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt;
      &lt;item name="android:windowIsFloating"&gt;false&lt;/item&gt;
      &lt;item name="android:backgroundDimEnabled"&gt;false&lt;/item&gt;  
  &lt;/style&gt;    
  </code></pre>
  
  <p><br>
  <code>manifest.xml:android:theme="@style/Theme.Transparent"</code>  i have used this in manifest.xml</p>
  
  <p>try to help me, to figure out the solution of this problem.
  Thanks.</p>