cancel
Showing results for 
Search instead for 
Did you mean: 

How to move an object (image, button, whatever) foreground or background

Zui
Senior

Greetings

In my current project i need a way to change the whole project style, so for now i'm changing just the background. my default background is just a colored box, but if another style is selected i wanna set an image as background, and thats is done easily, but i can't figure out how to move the just created behind pre-existing objects. I saw that in the viewBase class the object order is just the order which they are created, no functions to set their order (as far as i know), so i can't create my image as background, because the viewbase class is called before my implemantation. A temporaly solution found was creating the image in the designer with no image set (or with .setVisible(false)), but i was hoping for a better solution.

Thanks for any suggestion.

Stefano

1 ACCEPTED SOLUTION

Accepted Solutions
Martin KJELDSEN
Chief III

Hi @Zui​,

Sorry i missed this!

Let me show you how to manipulate the z-order programatically.

void swapBoxForImage()
{
    //remove all drawables
    remove(mybackgroundBox);
    remove(d1);
    remove(d2);
 
    add(myBackgroundImg);
    add(d1);
    add(d2);
}

View solution in original post

3 REPLIES 3
Martin KJELDSEN
Chief III

Hi @Zui​,

Sorry i missed this!

Let me show you how to manipulate the z-order programatically.

void swapBoxForImage()
{
    //remove all drawables
    remove(mybackgroundBox);
    remove(d1);
    remove(d2);
 
    add(myBackgroundImg);
    add(d1);
    add(d2);
}

Zui
Senior

yeah, i figured that out by myself watching some touchGfx examples, but tnx anyway ;)

Martin KJELDSEN
Chief III

Okay, glad you could find it on your own :)