我想用九补丁作为视图的背景。当视图大小小于我指定的最小值时,我希望它缩小。另一方面,当视图的大小大于指定的大小时,我希望这个可绘制的九面片像往常一样增长。以下是所需的可绘制行为的图示:

使用Nine-Patch drawables真的可以做到这一点吗?
发布于 2011-12-06 22:57:58
我不确定你是否正确地使用了九补丁,我宁愿使用九补丁的ImageButton作为背景,中间没有星星。然后,您可以在ImageButton上使用android:scaleType属性来根据需要缩放图像。
下面是一个例子(使用单独的可绘制图标在按钮上显示您的星形):
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/star"
android:background="@drawable/nine_patch"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:layout_weight="1" />https://stackoverflow.com/questions/8401623
复制相似问题