【问题标题】:dynamic size textview nativescript when you are writing a message编写消息时的动态大小 textview nativescript
【发布时间】:2018-03-05 10:20:10
【问题描述】:

我使用 angular2 在 nativescript 中创建了类似 whatsapp 的消息服务,当您在 android 平台上编写消息时,我遇到了 textview 的大小(高度)问题。当您添加另一行(如whatsapp或facebook等)时,我希望增加高度。

在 IOS 中,这很简单。点击链接

dynamic size of a textview in IOS

我的 html 模板是(只是屏幕的底部):

<StackLayout class="message-box-container">
            <GridLayout columns="auto, *, auto"
                        class="message-box">
                <Label col="0"
                       class="fa link"
                       [text]="'fa-link' | fonticon">
                </Label>
                <GridLayout columns="auto, *"
                            col="1"
                            class="message-box-field">
                    <TextView #newMessage
                              col="0"
                              editable="true"
                              hint="Write a message..."
                              textWrap="true"
                              [(ngModel)]="newMessage.text"
                              (ngModelChange)="textChanged()"
                              [style.height]="textHeight"
                              class="write-message-field"></TextView>
                    <Label (tap)="sendMessage()"
                           col="1"
                           class="fa arrow"
                           [text]="'fa-arrow-circle-up' | fonticon">
                    </Label>
                </GridLayout>
            </GridLayout>
        </StackLayout>

当你在 IOS 中输入时更改文本视图的大小:

 textChanged() {
        if (isIOS) {
            this.textHeight = this.newMessage.ios.contentSize.height;
        } else{//ANDROID TODO}

【问题讨论】:

    标签: android textview nativescript angular2-nativescript


    【解决方案1】:

    这比您想象的要容易得多,只是不要将height 设置为TextView / 将其设置为auto,这样它就会增长到需要的高度。

    【讨论】:

      【解决方案2】:

      动态文本视图高度。动态增加 textView 高度 它适用于android和ios

      <TextView height="auto" editable="true" hint="Write a message..." textWrap="true"[(ngModel)]="text" ></TextView>
      

      【讨论】:

        猜你喜欢
        • 2011-08-06
        • 1970-01-01
        • 2010-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多