For a custom AdapterView implementation I'd like to add a color overlay to selected items. How do I add a color overlay to a child of my AdapterView?
If you are using your own layout simply change the container to RelativeLayout (or a Layout class that inherits from RelativeLayout), and put the color overlay after the main layout. All you need is to add a View and set it's background and alpha. alpha set to the value 1 will activate this overlay, whereas setting alpha to 0 will go back to normal.
Example:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- add your views here -->
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#8000FF00" />
</RelativeLayout>
This will overlay a green layer with 50% alpha over the other views which are before it in the layout.
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