How can I add semi-transparent overlay on imageview?
change it to
Tap Edit and choose an image from your Photo Library or Stock Images. Scroll through the bottom menu and tap on Overlays.
You can add ImageView and VideoView in RelativeLayout and set ImageView to invisible and VideoView to visible and vice-versa and you can play video on onClick.
A simpler solution could be to use a ColorFilter on the ImageView with PorterDuff.Mode.SRC_OVER
ImageView.setColorFilter(ContextCompat.getColor(
context,
R.color.black_opacity_200),
PorterDuff.Mode.SRC_OVER
);
If you want to get rid of the overlay simply clear it
ImageView.clearColorFilter()
for me, the selected answer didn't worked.But I got it using layer-list..All you got to do is to create a filter file(having your topmost color), a layer-drawable file(joining your filtercolor and image) and use this layer-drawable in your image view.
filter.xml
<shape
android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#cf64b5f6"
android:endColor="#cf1E88E5"
android:angle="270"
/>
</shape>
layerlist_drawable.xml
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/my_img" />
<item android:drawable="@drawable/filter" />
</layer-list>
main_activity.xml :
<ImageView
android:layout_width="match_parent"
android:layout_height="180dp"
android:scaleType="centerCrop"
android:src="@drawable/layerlist_drawable"
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With