I got the captured image(bitmap image) through camera content in android but I need to get 50% transparency of that image and it should be displayed on ImageView. How to do this?
Asked
Active
Viewed 99 times
1
-
Just set that image in `ImageView` and take a look at [Android and setting alpha for (image) view alpha](http://stackoverflow.com/questions/4931071/android-and-setting-alpha-for-image-view-alpha) – Ravi Feb 22 '17 at 06:45
-
Check http://stackoverflow.com/questions/17389023/how-to-set-imageview-transparent – Komal12 Feb 22 '17 at 06:47
-
i don't want image view as transparent.I need bitmap image as transparent because i want to make this transparent image on top of another image which should be displayed on imageview – sameera varma addepalli Feb 22 '17 at 07:27
5 Answers
1
Set this android:alpha="0.5"
attribute to your ImageView
.
<ImageView
android:id="@+id/e4"
android:layout_width="200dp"
android:layout_height="100dp"
android:background="@color/colorAccent"
android:alpha="0.5" />
you can set alpha
value between 0 to 1 for Transparency in Imageview
.

Chetan Joshi
- 5,582
- 4
- 30
- 43
0
Try using this alpha transparency attribute:
http://developer.android.com/reference/android/view/View.html#attr_android:alpha
android:alpha="0.5"
Will give you 50% alpha transparency to the View.
For ex:
<ImageView
android:id="@+id/Imgexample"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/example"
android:alpha="0.5" />

Athul
- 801
- 7
- 16
0
If your purpose is to just display with transparency then, you simply use ImageView's setImageAlpha
imageView.setImageAlpha(int)
Value ranges from 0-255
0 being transparent and 255 being opaque

Chintan Soni
- 24,761
- 25
- 106
- 174
0
Try to set transparency on ImageView
with setAlpha(float)
method.. where 0f
is full transprent and 1f
is fully opaque.
ImageView myImage = (ImageView) findViewById(R.id.myImage);
myImage.setAlpha(0.5f);

Somesh Kumar
- 8,088
- 4
- 33
- 49
0
set android:alpha=0.5
property for you ImageView
refer this:
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.5"
/>
-
-
I think you can achieve this using Frame Layout . refer this http://stackoverflow.com/questions/33864422/android-imageview-overlay-another-imageview. – Feb 24 '17 at 09:29