Thread
#compose
    myanmarking

    myanmarking

    11 months ago
    if i want to draw a fixed size colored rectangle, with a logo inside. Should i use an image inside a box? surface ? other? i never know
    OG

    OG

    11 months ago
    I think it may depend on how you want this component to lay out compared to others at the same elevation or what you're trying to do. In this case I think Surface with a background color is preferred over Box, since Surface will correctly set the appropriate content color. (For your inner Image) Using modifier.background on Box or other composables doesn't set the corresponding content color.
    myanmarking

    myanmarking

    11 months ago
    yeah. i may have to read about it. i noticed lots of components have content color. idk what is that and what it influences the views
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    11 months ago
    It probably doesn't matter unless your logo is a vector image, although even then if it's branding it probably is very particular about its color. I would start with the simplest thing and only go more complex if you actually need to:
    Image(logo, modifier = Modifier
      .background(Color.Red)
      .size(width, height)
      // Allow the logo to set its own size and center in the box
      .wrapContentSize()
    )
    myanmarking

    myanmarking

    11 months ago
    uhh that works? I dismissed it at first, i assumed if i specified size, the image would have that same size. I’m gonna try. Thanks!!
    well, that works ya. but then, how can i specify gravity for the image? The Container is a Square, and the logo is at the bottom
    oh . its a param of wrapContent. this is nce!