I have a RelativeLayout that has a 9-patch background image. The image is a simple speech bubble with a perfectly centered "arrow" at the bottom middle.
The RelativeLayout is inflated and placed on a MapView. Using the emulator, the speech bubble can be easily pointed to a location and will expand to its contents (text, an image, or both). When I run my app on a phone however, the 9-patch doesn't stretch properly. The "arrow" for the speech bubble will be offset to the left by a very noticeable amount.
I primarily test on a Nexus S, but also a Samsung Captivate and Nexus One. Targeting SDK 7. Tested emulators for SDK 7+. Only hardware devices seem to have this problem.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:id="@+id/BubbleLayout"
android:background="@drawable/bubble"
android:layout_width="wrap_content"
android:gravity="center_horizontal">
<TextView android:layout_height="wrap_content"
android:id="@+id/date"
android:layout_width="wrap_content"
android:maxWidth="196dp"></TextView>
<TextView android:layout_below="@+id/date"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:maxWidth="196dp"
android:id="@+id/summary"></TextView>
</RelativeLayout>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…