1

How to add a transparent overlay to a selected imageview?

I have a recyclerview. The user can perform deletion by long pressing the items. I want to highlight the items

What i did is this-

1) Along with the items i created a View and made it invisible android:visibility="invisible" .

2) Made it visible if it selected in onBindViewHolder()

viewHolder.overlay.setVisibility(isSelected(i) ? View.VISIBLE : View.INVISIBLE);

what i get is this

enter image description here

what i actually want is this, a transparent overlay

enter image description here

How can i achieve this?

user305774
  • 123
  • 15

1 Answers1

1

Found a simple solution. This can be done using transparent hex code colors.

you can see here.

so View in my xml is as follows

 <View
    android:id="@+id/selected_overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#7618AB8E"<!-- 76 for transparency -->
    android:visibility="invisible"
    />
Community
  • 1
  • 1
user305774
  • 123
  • 15