2

I am interested in creating the following effect: a gradient (dark grey) overlay with icons over the Android Video Player on the phone. How could I achieve this? Also, how can I make this overlay/gradient fade away after a certain amount of idle time? Thank you.

enter image description here

code
  • 5,294
  • 16
  • 62
  • 113
  • you can easily add an overlay simply by making a LinearLayout or similar with a background that has the color (shade, including alpha value) you want. Later, when you want to fade it, you can use an animation to change the alpha of the overlay and make it completely disappear – Martin Dec 08 '14 at 22:36
  • Thanks Martin, do you have any sample code for this? Also, when making the item fade, should there be an asynchronous task to check for idle key press? And is there a callback when the animation has completed disappearing? – code Dec 09 '14 at 04:41

1 Answers1

2

Sure. Here's the XML snippet for the overlay

.
.
.
    </RelativeLayout>
</ScrollView>

<View
    android:id="@+id/overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/loading_overlay"
    android:visibility="gone" />
</LinearLayout>

I put the 'overlay' at the end of the entire layout so it is on top. I set it initially to "gone" so it doesn't show up. Then in my Java,

    overlay = (View) v.findViewById(R.id.overlay);
    overlay.setVisibility(View.GONE);

If your layout the view resides in, in my case a LinearLayout, has "animateLayoutChanges' set to true, then the default animation when I set the overlay to gone is to simply fade away. Very easy peasy

Martin
  • 4,711
  • 4
  • 29
  • 37
  • Now... i just need to figure out how to "know" when the user has been idle. That way, I will trigger this fade out animation after a few seconds. – code Dec 10 '14 at 01:26