title: Making Custom Android SurfaceView Transparent
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5391089/how-to-make-surfaceview-transparent">how to make surfaceview transparent</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to make a custom surface view semi translucent. Currently the activity is transparent so I can see the activity before it underneath, but as soon as I add my custom view that is 20dp * 20 dp (called ControlsOverlayView) it shows up as a black square on the screen. I have seen this post <a href="https://stackoverflow.com/questions/1377336/how-to-make-a-listview-transparent-in-android">How to make a ListView transparent in Android?</a> and have tried setting background color, cachehint and alpha of the view to no avail. </p>
  
  <p>The transparent activity housing the view is ControlsOverlayActivity.java: </p>
  
  <pre><code>public class ControlsOverlayActivity extends Activity {
  
      private ControlsOverlayView overlay;
  
      @Override
      protected void onCreate(Bundle savedInstanceState){
          super.onCreate(savedInstanceState);
          setContentView(R.layout.test);
          TextView textView = (TextView) findViewById(R.id.test_text);
          try {
              textView.setText("test");
          } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }   
      }
  }
  </code></pre>
  
  <p>The test.xml layout including a sample TextView and my custom ControlsOverlayView is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/test"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;
  
    &lt;TextView android:id="@+id/test_text"
      android:layout_width="match_parent"
      android:layout_height="match_parent"/&gt;
  
    &lt;wp.ui.ControlsOverlayView
      android:layout_width="20dp"
      android:layout_height="20dp" 
      android:background="#00000000"
      android:cacheColorHint="#00000000"
      android:alpha="0"
      /&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p>and view:</p>
  
  <pre><code>public class ControlsOverlayView extends SurfaceView implements Runnable, Callback{
  
      public ControlsOverlayView(Context context, AttributeSet attrs) {
          super(context, attrs);
  
          // make sure we get key events
          setFocusable(true);
          setFocusableInTouchMode(true);
          requestFocus();
  
          // register our interest in hearing about changes to our surface
          getHolder().addCallback(this);
      }
  
      @Override
      public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
          //resize(getWidth(), getHeight());
          //paintControls();
  
      }
  
      @Override
      public void surfaceDestroyed(SurfaceHolder arg0) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void run() {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void surfaceCreated(SurfaceHolder holder) {
          // TODO Auto-generated method stub
      }
  
  }
  </code></pre>
  
  <p>also in my manifest i have:</p>
  
  <pre><code>&lt;activity android:name=".ui.ControlsOverlayActivity" android:theme="@style/Theme.Transparent"&gt;
          &lt;/activity&gt;
  </code></pre>
  
  <p>and the Theme.Transparent is defined as:</p>
  
  <pre><code>&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;@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:backgroundDimEnabled"&gt;false&lt;/item&gt;
    &lt;/style&gt;
  </code></pre>
  
  <p>Again it is just the custom view that can`t get to be transparent. Any ideas?</p>