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: 
joetesta
Level 10

how to obtain computed height of Label ?

Sorry for the double posts.  I need help and the docs appear to be wrong, so I'm covering the bases.
https://sdkdocs.roku.com/display/sdkdoc ... lAlignment
How does one obtain the computed height?  I've tried every scenario of setting heights and numlines and maxlines to zero and non-zero.  
Whenever I set height 0, after dynamically assigning the text and retrieving the component's height, it is always 0, regardless of numlines being non-zero or maxlines being non-zero.
please help?
aspiring
0 Kudos
3 Replies
Roku Employee
Roku Employee

Re: how to obtain computed height of Label ?

"joetesta" wrote:
Whenever I set height 0, after dynamically assigning the text and retrieving the component's height, it is always 0,

What makes you think that it will change?
Perhaps you are mis-reading, the doco text you link to talks about "computed height" value, how it is done - does not imply that would be exposed to you though - and even if it is, i am pretty sure that won't be back in "height". Have you tried boundingRectangle and other such? (disclaimer: i am talking unprepared on the subject)
0 Kudos
joetesta
Level 10

Re: how to obtain computed height of Label ?

"RokuNB" wrote:
"joetesta" wrote:
Whenever I set height 0, after dynamically assigning the text and retrieving the component's height, it is always 0,

What makes you think that it will change?
Perhaps you are mis-reading, the doco text you link to talks about "computed height" value, how it is done - does not imply that would be exposed to you though - and even if it is, i am pretty sure that won't be back in "height". Have you tried boundingRectangle and other such? (disclaimer: i am talking unprepared on the subject)

I don't necessarily think it will change, but this computed height might be useful for layouts, no?  I did look at boundingRect and that didn't seem to have any useful info, I'll go double check in a few.  I need to put a UI element under this variable height paragraph and unfortunately it seems I cannot use simple Label component.  Now I believe it's not exposed, which sucks. But maybe, hopefully I'm wrong?
aspiring
0 Kudos
joetesta
Level 10

Re: how to obtain computed height of Label ?

boundingRect() works after all! Seems it's just a matter of looking at boundingRect() after the dynamic text is set.
Thanks RNB, you are the best!
aspiring
0 Kudos