简体   繁体   中英

How to resize an image/chat bubble accordingly?

I am making something like the WhatsApp Chat. When you send a message, a greenish rectanglepops up with a small arrow on the top right hand which resizes according to the amount of text you put in.

I would like to ask for help in doing the same using Xamarin Android (C#)

How do I resize a rectangle according to the text one inputs??

Thanks!!

PS - Please provide me the greenish color of the rectangle whatsapp uses

I don't know how Xamarin does it but in Android we use 9-patch images for these kind of backgrounds. It is very simple actually. You can check the below links.

http://radleymarx.com/blog/simple-guide-to-9-patch/

http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html

Using a textview you can set a background for it. add some padding so the text doesnt go off the edge. if the background image is a bubble it should stretch to the text.(try use a slightly high res).

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