Search code examples
androidcustom-viewviewgroupnine-patch

Nine patch on a custom viewgroup


I made a nine-patch, and a custom viewgroup, then I made the background of that viewgroup to be the nine-patch.

The problem is: The nine-patch is ignoring the "content area" settings.

So: How I use a nine-patch properly in a custom view?

OR:

How I grab the content area from the nine-patch so I can use it on the OnMeasure and OnLayout math?


Solution

  • Also use boolean getPadding(Rect padding) on the NinePatchDrawable to get the padding for the content (your content + 9patch padding = total group dize)