1

我有一个小部件,当我使用颜色作为背景时,当我使用 android:layout_alignParentTop="true" 时,里面的所有组件都有一个 0 填充(其他方面也是如此)。

但是,当我使用 9 个补丁图像作为父级的背景时,当我将它们与父级对齐时,它的填充似乎等于 9 个补丁图像的不可拉伸大小。

这是正常的吗?

4

1 回答 1

7

There are two main parts to a nine-patch: the stretchable areas and the content-defined areas. The top and left pixel border define the stretchable area, as I'm sure you're aware. The bottom and right, however, define the CONTENT area. If you want the padding to go away, you need to make the bottom and right bar extend all the way to the edge of the artwork (not all the way to the corner pixels, though!). Basically, the right and bottom pixel border define your padding.

于 2011-06-10T21:16:09.077 回答