Android – Sliding overlay

While, I was working on one of the Android App, I needed a layout which offers overlay layer and provides a semi-transparent effect to view controls beneath it. In addition to the look & feel, I was also looking for a smooth transition effect to bring overlay in the view. It should also offer responsive touch to slide it out. The requirement seems to be very simple and my hunt began to implement such control. While I could able to locate many references for transition effect, none of them were perfect and had some flaws in it. The major flaw, I noticed with the implementation was that – Once an overlay view is displayed, sliding it to the right, will sometimes cause controls beneath it receiving events and yielding weird results. The rationale behind it was simple, the usage of setOnTouchListener doesn’t provide enough control over the touch lifecycle of a control and hence the touch event was getting leaked to the controls, visible one layer below.