How to use an image as background in HorizontalBox?

Hi.
I’m newbie to UE4. I have generated a HUD using UMG that is a HorizontalBox.
I wanna use an image or color background in that horizontalbox.
When i create an image and set its parent to HorizontalBox it add as a new element to it logically.

Here is the HUD:

Here it is the hierarchy:

92459-hierarchy.png

Is there any tricks such as wrapping or somthing to do this?

2 Likes

You could wrap your Horizontal Box in an Overlay Panel and add and Image before the horizontal panel so that it lies beneath it:

92469-overlaypanelimage.png

Set the anchors of the image to fill its parent so that it fills the horizontal panels dimensions.

3 Likes

Thanks for your solution. And next question is how to fit this background with horizontal box? Duo to volatility of size of horizontalBox?

92517-newlayout.png

Very very thanks. I have used a complex trick to do this but i think your solution is much mush simpler than my solution.

I have wrapped overlay with a border and set the image to it. I have check out size to content of overlay too.

My solution with the overlay panel is good if you have a complex hierarchy since an overlay panel can have multiple children. For example you can add multiple images to use as a background to add more details.

If you just have one child, your solution with a Border Panel is simpler (and I guess the intended use). See image with a Border Panel:

1 Like

I have attached the size settings for the different panels.
The overall layout:

Set the overlay panel to “size to content”:

92528-overlaypanelsettings.png

Set the image size to fill in both directions:

92529-imagesettings.png

With this setup you can also achieve bordered panels. To do this grab a 9 tile border image (see [Setting Image States][4]) and set it as the image and give the horizontal box a padding:

92526-exampleborder.png