1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question Custom Fonts for Message Boxes

Discussion in 'Android Questions' started by DawningTruth, Jul 25, 2019.

  1. DawningTruth

    DawningTruth Active Member Licensed User

    My app has a particular look and feel which includes a custom font. When I use:

    xui.Msgbox2Async

    It uses the default font for the Modal Box.

    Is there any way to change the font to be the same as the custom font of my app?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Yes. Search for CSBuilder.
     
    DawningTruth likes this.
  3. DawningTruth

    DawningTruth Active Member Licensed User

  4. DawningTruth

    DawningTruth Active Member Licensed User

    inakigarm likes this.
  5. Erel

    Erel Administrator Staff Member Licensed User

    1. Never use Msgbox. Only MsgboxAsync (I've fixed it in the tutorial).
    2. If you post code as a screenshot it will not help as it is not possible to copy it.
     
    DawningTruth likes this.
  6. DawningTruth

    DawningTruth Active Member Licensed User

    Erel, thx for the guidance. Will remember for future posts.
     
  7. DawningTruth

    DawningTruth Active Member Licensed User

    Tried with the following code:

    Code:
    xui1.MsgboxAsync(csbuilder1.Initialize.Alignment("ALIGN_CENTER").Append($"My Message"$).Typeface(Typeface.LoadFromAssets("opensanscondensed-bold.ttf")).PopAll,"Message Title")
    The body of the message should be in the Open Sans font and the Heading in the default font. However they are both in the default font.
     
  8. DonManfred

    DonManfred Expert Licensed User

    You are not using CSBuilder for the title.
    You are not using CS Builder correctly

    Code:
    MsgboxAsync(cs.Initialize.Typeface(Typeface.LoadFromAssets("opensanscondensed-bold.ttf")).Alignment("ALIGN_LEFT").Append($"Lorem ipsum dolor"$).PopAll, _
    cs.Initialize.Typeface(
    Typeface.LoadFromAssets("opensanscondensed-bold.ttf")).Append("Test bla bla bla").PopAll)
    in my case i was setting two fonts and both, title and body, does have a different font in the result.
     
    Last edited: Jul 26, 2019
    Erel and DawningTruth like this.
  9. DawningTruth

    DawningTruth Active Member Licensed User

    Thx Don, that worked perfectly.

    Is there also a way to change the "Ok" to this font?
     
  10. DonManfred

    DonManfred Expert Licensed User

    1. New question; new thread
    2. I dont think so.
     
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