Android Question MeasureStringWidth with csBuilder

Discussion in 'Android Questions' started by fbritop, Mar 25, 2019.

  1. fbritop

    fbritop Active Member Licensed User

    Is there an alternative way to calculate the label width with different typeface?

    Code:
    cs.Initialize().Typeface(Typeface.FONTAWESOME).Size(Starter.subTitleSize).Color(color.appBlue).Append(Chr(0xF038)).PopAll
        cs.Typeface(fontNormal).Size(Starter.subtitleSize).Color(color.appBlue).Append(
    "LOG").PopAll
        l3.Text=cs

    l3.width=cv.MeasureStringWidth(cs, fontNormal, Starter.subTitleSize)
    I have to go two times to actually get the FONTAWESOME and the fontNormal width´s in order to get the total width. With this method FONTAWESOME are not being considered.

    Thanks
    FBP
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Canvas.MeasureStringWidth expects a string, not a CharSequence (CSBuilder). It will ignore the string attributes.

    I guess that the simplest solution will be to add a small gap as a compensation for this.
     
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