It's been a while since I've posted and I've read many posts to try to resolve my issue but I just can't seem to figure it out. I am missing something and I hope someone can help me understand what I am doing wrong.
In this example I have a TextView inside a Linear Layout with the LayoutParams set to MATCH_PARENT. If I use WRAP_CONTENT with the TextView the Shadow is being clipped, even if I use Padding. If I set the TextView to MATCH_PARENT the shadow isn't clipped.
TextView WRAP_CONTENT No Padding:
TextView WRAP_CONTENT with Padding
TextView MATCH_PARENT:
I've even tried it with ll.setClipToPadding(false); ll.setClipChildren(false);
What am I missing?
I don't think you're missing anything, unfortunately. This seems to be a bug with how TextView measures italic text. It's a problem even without shadows.
You'd have to subclass TextView
(or AppCompatTextView) and define custom measuring behavior to work around this.
If you don't want to bother with that, the consensus "best" answer is to add a non-breaking space to the end of your text in order to increase the measured size of the text. Unfortunately, this often adds more space than you really want.
Incidentally, android:clipToPadding
is only an attribute on ViewGroup
, which is why it doesn't do anything when you apply it to a TextView
(it is simply ignored, like any other unknown attribute).