Tarang
Tarang

Reputation: 75945

Android make a view transparent, or at least semi transparent

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

Upvotes: 4

Views: 13076

Answers (5)

Ross
Ross

Reputation: 1096

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)

Upvotes: 4

Franco
Franco

Reputation: 2761

You need to add slidingpanel:overlay="true" to SlidingUpPanelLayout, and then use the color on the transparent view as you decribed (android:background="@android:color/transparent" or whatever level of transparency you want).

Upvotes: 1

jyomin
jyomin

Reputation: 1967

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   

Upvotes: 3

Tushar Gupta
Tushar Gupta

Reputation: 15923

The color hex code is built like this. #ARGB or for a more fine grained control #AARRGGBB which means AlphaRedGreenBlue. Try some colour range for the transparency . the problem is with your hex code for color

Upvotes: 0

Android Stack
Android Stack

Reputation: 4314

try to refer it to drawable shape as bellow :

android:background="@drawable/transparant_layout"

transparant_layout:

<?xml version="1.0" encoding="utf-8" ?> 
 <shape xmlns:android="http://schemas.android.com/apk/res/android">
   <solid android:color="#00000000" /> 
 </shape>

Hope this help.

Upvotes: 0

Related Questions