Home ClipToPadding attribute to rescue.
Post
Cancel

ClipToPadding attribute to rescue.

Introduction

By setting ClipToPadding = false , The view draws beyond its bounds into the padding area, overwrite this drawing with the parent’s padding.

By default Android sets this property to true for any ViewGroup, which means they will be clipped to adjust to the padding of the ViewGroup.

Below images depicts better than any documentation.

In case of RecyclerView:

ScreenShot *image credits pulpfiction.

In case of Fab button:

ScreenShot

ScreenShot clipToPadding = false The shadow is drawn evenly, even if it exceeds the view bounds.

ScreenShot Whereas clipToPadding = true The shadow is clipped when it crosses the view bounds.
*image credits Samuel Peter.

Overall setting this property to false, in most cases leads to better UX.

More Reading:

1.StackOverflow answer

2.Android doc

This post is licensed under CC BY 4.0 by the author.