Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
thomsebastin
Level 7

Hide an element in Roku?

How do I hide an XML element using brightscript?

I am currently using
m.myElement.visible = false


but this behave like "visibility:hidden" (the element is hidden, but the space is preserved). I am after something like "display: none" where the element is hidden and space is not preserved. I have also used removeChild(), but I find it a bit tedious as I have to find the parent and then find the index of child I want to hide.. Any other easy alternative?
0 Kudos
3 Replies
joetesta
Level 10

Re: Hide an element in Roku?

if you don't want to remove the child you could try setting its height / width to 0 so that it's not taking up space
aspiring
0 Kudos
thomsebastin
Level 7

Re: Hide an element in Roku?

"joetesta" wrote:
if you don't want to remove the child you could try setting its height / width to 0 so that it's not taking up space

That's what I have been doing right now. But sometimes it doesn't just work. While typing this, It just occurred to me that the item spacing might be the reason for it to not remove the space. Appreciate your help. I will try without item spacing and see how that works out. 

Edit: Tried setting the height & width to 0. Doesn't just work. Tried setting the maxLines to 0, tried removing all the properties of the "Label". Turns out even the mere existence of "Label" tag without any properties add space. Is there a scenario where setting height & width to 0 doesn't work? Has anyone had any success with it? I am trying this on a "Label" tag.
0 Kudos
thomsebastin
Level 7

Re: Hide an element in Roku?

Setting the height to -1 (on .brs file) and setting it back to 0 when needed to be shown, works for me in my case. You can either set height or width to -1 to suit your use case. No problems as of now. If I bump into any problems w.r.t this, I will update here. Thanks.
0 Kudos