我创建了以下 9-patch PNG 图像
但是当我将它添加为按钮的背景时,我得到了以下结果:
如您所见,图片并未填满所有按钮背景!
这是 XML 布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/ninepatchimage"
android:text="Click ME" />
</LinearLayout>
谁能告诉我为什么??
最佳答案
看图片似乎没有被解析为 9patch,它应该被保存为 img.9.png
否则它将显示为普通图像
像这样:
关于android - 使用九补丁图像作为按钮android的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18007462/