19

I'm new to android application. enter image description here

In this picture,there is a bottom layout with some options like play,delete etc.., and has its transparency to show its background.

How to I get like that ?

Rakesh L
  • 1,136
  • 4
  • 18
  • 44
  • Brother,this is not ios UI .I took this from Google play store. – Rakesh L Jun 06 '13 at 06:22
  • Play Store doesn't look like that on any Android device I've viewed it on. If it does, then the OEM gets a -1. Those are iOS buttons, every single one. Is it perhaps a Samsung device? – Christopher Perry Jun 06 '13 at 06:26
  • I don't remember which app it was .i just crop a screen shot of an app in play store. – Rakesh L Jun 06 '13 at 06:32
  • 1
    So -1 to for whoever made that app then. I'm just saying, don't follow somebody else's bad design. Try to stick with the [Android Design patterns](http://developer.android.com/design/index.html). – Christopher Perry Jun 06 '13 at 06:41

5 Answers5

57

use android:background ="#88676767" change the first 88 to your selection of opacity

In reply to your comment:

ImageView iv = (ImageView) findViewById(your_imageId);    
iv.setColorFilter(Color.argb(150, 155, 155, 155),   Mode.SRC_ATOP);

Third option:

LinearLayout layout = (LinearLayout) findViewById(R.id.your_id);
    Drawable d = getResources().getDrawable(R.relevant_drawable);
    d.setAlpha(50);
    layout.setBackgroundDrawable(d);
baronS
  • 1,074
  • 11
  • 11
  • 1
    yes I got your point. I set an Image for background to that layout like this android:background="@drawable/myimage" .Then How to give another attribute again for android:background ="#88676767". – Rakesh L Jun 05 '13 at 11:33
  • 1
    I've added another option in the answer – baronS Jun 06 '13 at 06:09
  • Your use of `setAlpha` seems to be incorrect. It should be a value between 0 and 1 according to http://developer.android.com/reference/android/view/View.html#setAlpha(float) – faizal Jul 08 '14 at 05:02
  • There are 2 setAlpha's: the (int alpha) one takes its parameter between 0 and 255. from the documentation: alpha The alpha (0..255) to apply to the view's drawing. – baronS Jul 09 '14 at 08:00
  • I am going to have to downvote this. This does not work fine. It gives me a gray background which has no semitransparency – Daniel Viglione Jul 14 '17 at 02:39
17

The color format is ARGB, which means ALPHA/RED/GREEN/BLUE.

The transparency is set on the alpha channel, a value of 0 (0x00) is completely transparent and a value of 255 (0xFF) is completely opaque.

So if you need a grayish color half transparent, then set this color: #80444444

thiagolr
  • 6,909
  • 6
  • 44
  • 64
6

It's also incredibly easy to just set the alpha value, one of two ways. My example applies a 60% opaque black background to a linear layout.

The first method is to add the following line to change the alpha of the layout in the XML file (also in image):

android:background="@android:color/black"
android:alpha="0.6"

XML File Method

The second method is to change the alpha and background values in the design editor view:

Design Editor Method

ConcernedHobbit
  • 764
  • 1
  • 8
  • 17
3

Refer these links:

1.How to Set Opacity (Alpha) for View in Android

2. Android: how to create transparent or opeque background

Community
  • 1
  • 1
UdayKiran Pulipati
  • 6,579
  • 7
  • 67
  • 92
1

Use 32-bit PNG with transparency for your background (in that particular case, cause it does not have uniform transparency)

David Jashi
  • 4,490
  • 1
  • 21
  • 26