Java – Android makes View transparent, or at least semi-transparent

Android makes View transparent, or at least semi-transparent… here is a solution to the problem.

Android makes View transparent, or at least semi-transparent

I’m using AndroidSlidingUpPanel. So that you can see what’s underneath it. So it’s basically a mobile LinearLayout, but I don’t see what’s underneath.

I’ve tried setting alpha, background color (with alpha).

XML settings:

android:background="@android:color/transparent"

Also:

android:background="#22000000"

I also tried programmatically :

view.setAlpha((float) 0.45));

The problem is that everything I do doesn’t make it transparent. I can see the color change, but it’s still completely opaque.

Maybe I’m missing something? How can I make it transparent so I can see what’s below

Solution

Use android:alpha=”0.1″ to set the opacity of the layout

<FrameLayout
    android:id="@+id/frameLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:alpha="0.2"
    android:background="#000000"

https://developer.android.com/reference/ android/view/View.html#setAlpha(float)

Related Problems and Solutions