Android Question Canvas.MeasureStringWidth

Discussion in 'Android Questions' started by ykucuk, Oct 16, 2017.

  1. ykucuk

    ykucuk Active Member Licensed User

    Hi

    Canvas.MeasureStringWidth doesn't work when text is long or include CRLF

    Any help?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What are you using it for?
     
  3. ykucuk

    ykucuk Active Member Licensed User

    I am trying to create chat bubble. I need to change the width of bubble according to text length.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Assuming that Label.SingleLine is False then the text will be wrapped if it is too long. Canvas.MeasureStringWidth will return the string length without the text being wrapped.

    StringUtils.MeasureMultilineTextHeight will return the correct height with the wrapped text.
     
  5. ykucuk

    ykucuk Active Member Licensed User

    StringUtils.MeasureMultilineTextHeight is work fine.

    What I want to to do: message "ok" and "how are you" should be the different width. I need calc this width.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Canvas.MeasureStringWidth should work with these strings.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice