wrap_content is not working in button height android

前端 未结 6 983
灰色年华
灰色年华 2020-12-31 01:40

\"wrap_content\" is not working in my button, it currently looks like this:

 now                        want
 ____________
|            |           _________         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 02:19

    wrap_content will not shrink a button smaller than the background. If you are already using a nine patch for the background, then cut back the size of the regions to the smallest they can be. If there's not a gradient, then you only really need about two pixels to define the stretchable regions and then make sure the central area is as small as it can be. Use the padding (right and bottom lines on ninepatch) to allocate the padding.

    If you're using a drawable image (not a nine-patch or xml drawable) then make it a nine patch drawable

    If you don't want to solve the problem in the image, you will need to set the layout_height to a fixed value to force the image to shrink (ie don't use wrap_content)

提交回复
热议问题