Java Android按钮背景draw9patch不显示文本

Java Android按钮背景draw9patch不显示文本,java,android,android-button,Java,Android,Android Button,我已经成功地为按钮创建了draw9patch图像,并相应地进行了拉伸, 但它不显示按钮文本 <Button android:id="@+id/btnLocationDirection" android:layout_width="0sp" android:layout_height="38sp" android:background="@drawable/dire

我已经成功地为按钮创建了draw9patch图像,并相应地进行了拉伸, 但它不显示按钮文本

<Button
                android:id="@+id/btnLocationDirection"
                android:layout_width="0sp"
                android:layout_height="38sp"
                android:background="@drawable/directions_e"
                android:gravity="right|center_vertical"
                android:text="@string/location_direction"
                android:paddingRight="10sp"
                android:layout_marginLeft="5sp"
                android:layout_weight="1"
                android:textSize="14sp"
                android:textColor="@color/log_display_color"
                 />


其中方向是draw9patch图像。

您是否正确指定了9-patch图像的内容区域?请查看此处的文档以了解更多详细信息:将布局宽度设置为包裹内容是否有效?并删除paddingRight属性?你能发布你的9-patch吗?我试着将layout_width设置为wrap_content并删除paddingRight,但还是没有显示文本。解决了,我为图像绘制了错误的9-patch。