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
Hey, @Ericky14 you can implement your logic for creating maxLines / minLines rules for your TextView.
nativeScript allows you to work directly with the native APIs (Android and iOS) so you can extend the logic just as you would do in a native project.
Behind TextView stands android.widget.EditText for Android and UITextView for iOS, that said we ca use some native techniques to limit the number of lines.
e.g.
let tv = <TextView>page.getViewById("tv");
tv.text = "sample text";
if (isAndroid) {
let tvAndriod = tv.android;
tvAndriod.inputType = "text";
tvAndriod.maxLines = "3";
} else if (isIOS) {
tv.ios.textContainer.maximumNumberOfLines = 3;
tv.ios.textContainer.lineBreakMode = NSLineBreakByTruncatingTail;
}
tv.on("textChange", () => {
if (isAndroid) {
if (tv.android.getLayout().getLineCount() > 3) {
tv.android.getText().delete(tv.android.getText().length() - 1, tv.android.getText().length());
}
}
})
Thank you for your feature request - as a side note, I want to mention that NativeScript is open-source and everyone can become a contributor to the project. If you are interested in this option and you have a tested solution you can go through our contributing guide here.
@NickIliev, i want to add maxLines for android we can directly implement it in TextBase because it uses android.widget.TextView. but for ios TextBase uses UITextField | UITextView | UILabel | UIButton out of which UITextField doesn't support more than one line.
so my issue is where to write logic. is there any common approach available. or should i implement it in TextView, Label and Button separately.
Is there any workaround for having a scrollable textview after a certain number of lines?
I implemented @NickIliev workaround and it no longer accepts any input after reaching the maximum number of lines.
And right now, max-height is not yet implemented which is the possible workaround for having a scrollable textview.
Activity
NickIliev commentedon Jun 6, 2017
Hey, @Ericky14 you can implement your logic for creating maxLines / minLines rules for your TextView.
nativeScript allows you to work directly with the native APIs (Android and iOS) so you can extend the logic just as you would do in a native project.
Behind TextView stands android.widget.EditText for Android and UITextView for iOS, that said we ca use some native techniques to limit the number of lines.
e.g.
Demonstration project can be found here.
Thank you for your feature request - as a side note, I want to mention that NativeScript is open-source and everyone can become a contributor to the project. If you are interested in this option and you have a tested solution you can go through our contributing guide here.
bhavincb commentedon Jun 6, 2018
hey @NickIliev ,i would like to implement this to nativescript. but i have some doubts. where can i address them?
NickIliev commentedon Jun 6, 2018
@bhavincb this is what you need to create a PR - there is also a code convention guide included and development workflow. Create your PR with the codebase and test and the PR will be reviewed and if needed there will be a requests for changes.
Of course, the best practice would be to discuss the possible code feature or changes here in this very same issue.
bhavincb commentedon Jun 6, 2018
@NickIliev, i want to add
maxLinesfor android we can directly implement it inTextBasebecause it usesandroid.widget.TextView. but for ios TextBase usesUITextField | UITextView | UILabel | UIButtonout of whichUITextFielddoesn't support more than one line.so my issue is where to write logic. is there any common approach available. or should i implement it in
TextView, Label and Buttonseparately.LeoDupont commentedon Jul 10, 2018
@bhavincb, @NickIliev, do you have any news about this feature?
bhavincb commentedon Jul 10, 2018
@LeoDupont for now you can use workaround provided by Nichlliev.
codewithbjim commentedon Aug 8, 2019
Is there any workaround for having a scrollable textview after a certain number of lines?
I implemented @NickIliev workaround and it no longer accepts any input after reaching the maximum number of lines.
And right now, max-height is not yet implemented which is the possible workaround for having a scrollable textview.