I have a textview with a 9patch backdrop that has a drawn in dropshadow. The text is not centred in the defined frame but centred to the whole image dimensions including dropshadow. Checking it in the Draw9patch tool in the SDK shows the content space correctly but the text is ignoring this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/toast_frame2"
android:gravity="center"
android:padding="10dp"
android:text="Toast text"
android:textColor="#444444"
android:textSize="10sp" />
</LinearLayout>
How do I get the textview to use the 9patch definitions?
There's no way for the framework to understand that you're drawing a shadow. You need to center the frame. Measure the pixels between the frame and the edge on the right of your 9-patch, then insert that many blank pixel columns between the left edge of your frame and left edge of the 90-patch. Repeat for the top.
Adjust padding to prevent the text from overlapping the frame's edge.