简体   繁体   English

如何相应地调整图像/聊天气泡的大小?

[英]How to resize an image/chat bubble accordingly?

I am making something like the WhatsApp Chat. 我正在做类似WhatsApp聊天的事情。 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#) 我想寻求使用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 PS-请提供给我whatsapp使用的矩形的绿色

I don't know how Xamarin does it but in Android we use 9-patch images for these kind of backgrounds. 我不知道Xamarin是如何做到的,但是在Android中,我们将9色块图像用于此类背景。 It is very simple actually. 实际上,这非常简单。 You can check the below links. 您可以检查以下链接。

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

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

Using a textview you can set a background for it. 使用textview可以为其设置背景。 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). 如果背景图像是气泡,则应拉伸到文本。(尝试使用稍高的分辨率)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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