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?
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
frangulyan You're missing the other bit of code from your credited answer. The below solution worked for me.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
LinearLayout rootView = (LinearLayout) inflater.inflate(R.layout.fragment_main, container, false);
//This can be done in XML
rootView.setClipChildren(false);
rootView.setClipToPadding(false);
return rootView;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
//This is the NoSaveStateFrameLayout - force it to not clip
FrameLayout frameLayout = (FrameLayout) getView();
frameLayout.setClipChildren(false);
frameLayout.setClipToPadding(false);
}
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