I created a custom background image and wanted to use it as the background for a layout that has height of wrap_content. However, the total height of the contents of within that layout are much less than the height of the background image.
When I set it as the background in XML via android:background="@drawable/image", I noticed that it displays the entire height of the image, although the height of the actual contents are much shorter.
Is there a way to stop this from happening?
Thanks.
I had a similar problem and was using a 9patch. The full 9 patch image was showing as a background even though the content it was attached to wasn't that big (was using wrap_content). I'm not sure why Android chose to show the full image instead of scaling the background to fit the content.
However, I fixed the problem by scaling down my background image. By that I mean preserving the corners but scaling down the vertical and horizontal portions. See the attached images of the background frame I had before and the result of the resize effort.
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