Search code examples
androidgraphicsnine-patch

image rendering nine patch


I have a list view with a custom layout. In the layout I display a series of comments. The problem is the image I've set as the background gets stretched when the comments are too long.

I know I could probably use a nine patch but the question is would it really work? If not what alternative do I have?

Could someone recommend the best of handling this.

what happens to the image

enter image description here

<TextView android:id="@+id/txtCommentBody" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" android:textColor="@color/black" android:paddingTop="25dip" android:paddingLeft="5dip" android:paddingRight="5dip" android:layout_marginTop="10dip" android:background="@drawable/comment_bg"> </TextView>


Solution

  • A nine-patch would work provided you pad the top of your text so it's below the part that won't scale. Alternatively, truncate all your comments to some reasonable length that will fit, and let people click them to read the whole thing.