How to dynamically change Layer order in a GridLayout

layereditems
uiux

#1

Based on a request from this thread,
https://discourse.nativescript.org/t/how-to-layer-items-in-nativescript

I have made a sample NS Playground app to dynamically change the order of layers in a GridLayout.

Here’s the link to it.

Here’s the trick. You just remove and add that element to the same grid layout.

Remove by doing, gridLayout.removeChild(element);

Add by doing, gridLayout.addChild(element);

hope this is useful to someone out there!, Cheers. Happy NativeScripting :slight_smile:

Here’s the result


How to layer items in NativeScript
#2

smart hack :thinking:


#3

@ganas
Initially, I was unsure whether this would work because the element does contains the details of the row and column.
Thanks to playground, I could try it out quickly.


#4

Cool stuff, dude! @multishiv19 I like! :+1:


#5

Thanks @kommitareeben :smiley: