17

I have the folowing layout:

enter image description here

I want to make transparent the transparent_layout but i can't do it.

Already tried settings the background programmatically with the color: Color.TRANSPARENT but it seems it doesnt work.

Im using Android 2.3.3 SDK with SherlockActionBar.

Is there any way to set that layout to transparent?

Narendra Singh
  • 3,990
  • 5
  • 37
  • 78
alxsimo
  • 567
  • 1
  • 6
  • 19
  • 1
    Post the layout.xml file for clarity – CRUSADER May 08 '13 at 12:34
  • and also the code you are using the set the background color since you mentioned you're doing this programmatically. You have to use `setBackgroundColor` and not `setBackground` (just sayin' incase that's the issue). – Ali May 08 '13 at 12:37
  • http://stackoverflow.com/questions/3114675/transparent-background – Raghunandan May 08 '13 at 12:42
  • @CRUSADER, here you have the layout (http://pastebin.com/07rW2DWD). – alxsimo May 08 '13 at 14:40
  • @Ali im using setBackgroundColor, sorry, my mistake. – alxsimo May 08 '13 at 14:41
  • @Raghunandan i need to aply transparency to a layout, not a entire activity, please read well my post. I already tried that way. Thanks – alxsimo May 08 '13 at 14:42
  • 1
    @Alexandru you can apply the same to your layout. modify the same accordingly – Raghunandan May 08 '13 at 14:44
  • @Raghunandan, i tried the example but it still dont work :( I tried this project (http://blog.stylingandroid.com/archives/1021) in my mobile and it works, the problem its not the sdk, there is something wrong in my ui.. – alxsimo May 08 '13 at 15:16
  • 1
    Try [this link](http://stackoverflow.com/a/8968905/2345913). I think its close to what you want to achieve – CRUSADER May 08 '13 at 16:53
  • Don't forget to mark this question as resolved. – Jonathan Liono Mar 28 '14 at 12:07

3 Answers3

45

Depending upon the degree of opacity you like, set the background color like

        android:background="#00ffffff"

The first two digits are for opacity level, (aka alpha) that varies from 00 to ff (fully-transparent to fully-opaque), the remaining digits are for the desired background color. If you keep first 2 digits zero (00), then whatever color you choose for the remaining digits, doesn't matter.

AplusKminus
  • 1,542
  • 1
  • 19
  • 32
Narendra Singh
  • 3,990
  • 5
  • 37
  • 78
6

In XML change the main layout's (LinearLayout) background as android:background="@android:color/transparent" and also make sure that you are not giving the background to any of its child views.

SiHa
  • 7,830
  • 13
  • 34
  • 43
bakriOnFire
  • 2,685
  • 1
  • 15
  • 27
  • you can give it a try [How to create Transparent Activity in Android?](http://stackoverflow.com/a/2700683/2310673) – bakriOnFire May 08 '13 at 16:57
5

Try this:

android:background="@android:color/transparent"
DroidBender
  • 7,762
  • 4
  • 28
  • 37