setClipChildren and hardware layers

android, android-animation

Solution

Try to use following combination:

setClipChildren(false);
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
android:hardwareAccelerated="false"

As described here: ViewPager and setClipChildren(false) workaround for 2.x devices

Problem

I have a custom view group that I'm animating around on a screen based on touch events (drag and drop, for instance). I want it to be able to draw slightly outside its bounds, and still animate smoothly. I tried setting setLayerType(LAYER_TYPE_HARDWARE, null) on the dragging view, and performance was great, but anything outside the bounds was clipped. I tried setting LAYER_TYPE_NONE, performance was still fine, but there was animation ghosting/streaking where the view had been dragged (as if it were smearing the screen). Tried this on a Moto X and Nexus 4, same results. What's the best way to approach this? Is setClipChildren(false) supposed to work with LAYER_TYPE_HARDWARE? Interestingly, LAYER_TYPE_SOFTWARE exhibits the same unexpected clipping as does LAYER_TYPE_HARDWARE.

Original source