Hazneliel Hazneliel - 5 months ago 79
Android Question

Android animate view outside fragment is getting clipped

I have a view in a fragment. This fragment is within a FrameLayout. I want to animate this view moving outside the fragment borders. However, the view always get clipped when crossing the border. I have tried by setting "android:clipChildren='false'" and android:clipToPadding="false" to everything, but I can't get it to work.

Is this even possible to do?

Answer

I had the similar problem with fragments and put android:clipChildren="false" and android:clipToPadding="false" on all the levels in my hierarchy, but it was still not working. The trick that worked for me was to add this override in my fragment code:

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ViewGroup vg = (ViewGroup) view;
    vg.setClipChildren(false);
    vg.setClipToPadding(false);
}

Hope this helps...

P.S. the credit should go to this answer