简体   繁体   中英

Nine-patch image shows strange behaviour?

I am creating an app in Android which implements Chat feature in it. I have 2 kind of chat bubbles - blue for other user and orange for logged in user. I am using Nine-patch images for these bubbles because the bubble can be stretched.

The text in the blue bubble is showing fine - right in the center(as shown in the figure below). But the text in the orange bubble is showing after some vertical gap from the upper border of the image. I can't figure out why this is happening. Both the bubbles have same properties and have been created following the same procedure. Please help. Thanks in advance.

chatbubbles

Here is the orange chat bubble:

orangebubble

The problem is in the nine-patch.. the right hand border defines where the content goes and you have it starting just under the pointy part of the speech bubble. Continue the border up to where you want the content to start and it will work!

To clarify: the right and bottom borders define where the content can go, and the top and left borders define the area of the image that will be repeated when the image needs to be stretched.

Try this: 在此输入图像描述

draw9 will stretch as what you want.

//your image width is too long. use this one for your reference. //this image will work fine for me as I am using for left side.

your orange chat bubble is also fine if you put one dot on the right side above the arrow.

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM