LinearLayout translucent (but not transparent)

I would like LinearLayout to be translucent (I don't mean transparency). I want to imitate the dialogue in my work. So I tried this:

In the manifest:

android:theme="@android:style/Theme.Translucent"

In Activity onCreate:

LinearLayout MyLayout = (LinearLayout)findViewById(R.id.MyLayout);  
MyLayout.setBackgroundColor(Color.BLACK); 
MyLayout.getBackground().setAlpha(50);

But this does not work, because I do not see the Home desktop at all. Any idea?

I also tried this in xml, but it doesn't work either:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/MyLayout"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:background="#22FFFFFF"
   android:orientation="vertical" >
</LinearLayout>
+3
source share
1 answer

Use a hexadecimal color code that consists of two digits for alpha and six for the color itself, for example:

android:background="#22FFFFFF"

This will make it translucent.

+2
source

All Articles