You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you can't wait for this to be implemented I suggest you to do it by calling the native APIs (setLineSpacing on Android or follow this thread for iOS)
For people that end up here before it is implemented, this is the manual way to do it.
functionlabelLineHeight(nsLabel){if(isIOS){varlabel=nsLabel.ios;varattributedString;if(label.atributedText){attributedString=label.atributedText;}else{attributedString=NSMutableAttributedString.alloc().initWithString(label.text);}varparagraphStyle=NSMutableParagraphStyle.alloc().init();paragraphStyle.lineSpacing=5;varrange=NSMakeRange(0,label.text.length);attributedString.addAttributeValueRange(NSParagraphStyleAttributeName,paragraphStyle,range);label.attributedText=attributedString;}if(isAndroid){varlabel=nsLabel.android;//Default spacing is 20% of text size//setLineSpacing(add,multiplyby);label.setLineSpacing(12,1);}}
Reacted by Mike Branstein, d.a.nicholls, abdallahbedir, Luke Ramsden, Gabito Esmiapodo and Nathan Walker
@AntonioCuevaUrraco I'm using this approach on several static pages, and it works well.
I occasionally run into an issue with labels that are data bound in iOS (I haven't tried on Android yet). It seems like I need to re-apply the paragraph style each time the text changes in the label. I don't know enough about iOS under the hood to be able to confirm this - does it sound right?
@mbektchiev NativeScript has their own label.ios.atributedText on the core modules to set the properties that are supported on the css. I am not 100% sure but I think you have to re-apply on text changed because the ns core is overriding the atributedText that you just changed with the "original" one.
This issue is a year old now and still not implemented. The code-behind workaround is good, but if your text is centered, then on iOS when you enter the view you can see it centered with the normal line-height, then left-aligned with the new line-height, then center-aligned with the new line-height - which really weird to the user.
Any ETA for this?
Reacted by David Benninger, Alexander Bachmann, Luke Ramsden, Oliver Ochs and Christian Hartmann
Oh yes please. It's so hacky to change the line-height in "native" code. The other problem is that the UI is not refreshed after the change and the text is cutted because the container element doesn't change the height.
Reacted by Oliver Ochs, Luke Ramsden, Daniel Pinto and Marco Marques
Activity
vjoao commentedon Feb 28, 2016
If you can't wait for this to be implemented I suggest you to do it by calling the native APIs (
setLineSpacingon Android or follow this thread for iOS)burkeholland commentedon Feb 29, 2016
👍
AntonioCuevaUrraco commentedon May 13, 2016
For people that end up here before it is implemented, this is the manual way to do it.
mikebranstein commentedon Aug 16, 2016
@AntonioCuevaUrraco I'm using this approach on several static pages, and it works well.
I occasionally run into an issue with labels that are data bound in iOS (I haven't tried on Android yet). It seems like I need to re-apply the paragraph style each time the text changes in the label. I don't know enough about iOS under the hood to be able to confirm this - does it sound right?
AntonioCuevaUrraco commentedon Aug 17, 2016
@mbektchiev NativeScript has their own label.ios.atributedText on the core modules to set the properties that are supported on the css. I am not 100% sure but I think you have to re-apply on text changed because the ns core is overriding the atributedText that you just changed with the "original" one.
lukeramsden commentedon May 9, 2017
This issue is a year old now and still not implemented. The code-behind workaround is good, but if your text is centered, then on iOS when you enter the view you can see it centered with the normal line-height, then left-aligned with the new line-height, then center-aligned with the new line-height - which really weird to the user.
Any ETA for this?
Acanguven commentedon May 11, 2017
I am looking for this too. It is a really useful feature.
NickIliev commentedon Jun 19, 2017
+1 from t.1114872
simonox commentedon Jun 20, 2017
+1
Pinny3 commentedon Jun 20, 2017
Come on, this is one of a basic functionality that I expect from a framework which is based on CSS. So, when can I expect this?
+1
bitworking commentedon Jun 29, 2017
Oh yes please. It's so hacky to change the line-height in "native" code. The other problem is that the UI is not refreshed after the change and the text is cutted because the container element doesn't change the height.
3 remaining items
mikebranstein commentedon Aug 1, 2017
@EddyVerbruggen and other {N} team, thanks for the updates! We appreciate you all!
Added line-height css property (#919)
lock commentedon Aug 28, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.