Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android make a view transparent, or at least semi transparent

Tags:

java

android

I'm using the AndroidSlidingUpPanel. I'm trying to make one of the views semi-transparent. So that you can see what's under it. So its basically a LinearLayout which moves, but I can't see whats underneath.

I've tried setting the alpha, the background color (with alpha)

xml settings:

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

as well as:

android:background="#22000000"

I've also tried programmatically:

view.setAlpha((float) 0.45));

The thing is everything I do doesn't make it transparent. I can see the colours change but its still fully opaque.

Perhaps i've missed something? How can I make it transparent so I can see whats underneath

like image 381
Tarang Avatar asked Feb 15 '23 10:02

Tarang


2 Answers

Use android:alpha="0.1" to set opacity of a 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)

like image 100
Ross Avatar answered Feb 20 '23 10:02

Ross


In XML set Background attribute to any colour White(#FFFFFF) shade or Black(#000000) shade.if you want transparancy just put 80 before the actual hash code.

#80000000   
like image 23
jyomin Avatar answered Feb 20 '23 09:02

jyomin