Android 上的 ScrollView 在调整大小后未呈现

ScrollView on Android not rendering after resize

创建简单聊天

<Page
 actionBarHidden="true"
> 
 <GridLayout columns="*" rows="1*,8*,1*">
  <StackLayout row="0" class="form"  background="#FAE379" >
   <Label class="lbl-menu" fontSize="20" marginBottom="1%" @tap="$navigateBack">
    <FormattedString>
     <Span fontSize="15">{{'fa-chevron-left' | fonticon}}</Span>
     <Span fontSize="20" class="txt-btn">     Test</Span>
    </FormattedString>
   </Label>
  </StackLayout>

  <ScrollView  row ="1" id="myScroller">
   <StackLayout >
    <StackLayout v-for="(m,i) in messages" :key="i" marginTop="30">
     <StackLayout class="card-chat-msg-o" v-if="m.u">
      <StackLayout>
       <Label class="card-chat-text-o"  textWrap="true" :text="m.txt"/>
      </StackLayout>
     </StackLayout>
     <StackLayout class="card-chat-msg-u" v-else>
      <StackLayout>
       <Label class="card-chat-text-u"  textWrap="true" :text="m.txt"/>
      </StackLayout>
     </StackLayout>
    </StackLayout>
   </StackLayout >
  </ScrollView  >

  <GridLayout row ="2" columns="1*,8*,1*" rows="*" borderColor="#F1F1F1" borderWidth="2%">
   <Label col="0" class="fa" fontSize="30">{{'fa-paperclip' | fonticon}}</Label>
   <TextView col="1" editable="true" v-model="message" hint="Enter message" autocorrect="true"/>
   <Label col="2" class="fa" fontSize="30" @tap="sendMessage()">{{'fa-play' | fonticon}}</Label>
  </GridLayout>

 </GridLayout>
</Page>

当我关注 TextView 时,android 显示键盘,ScrollView 部分重叠且消息的底部项目不显示

然后我在消息中推送新项目

ScrollView 仅在正确位置显示新消息,其他消息项未显示

https://yadi.sk/i/R7F7sELLYZAREw

ListView也有类似的问题

https://play.nativescript.org/?template=play-vue&id=5jP4yP

看来您的布局有问题,在我看来您的嵌套布局太多了。我已经构建了一个类似的 example here,它可以在屏幕上使用相对较少的 UI 元素为您提供所需的内容。

除了嵌套布局,我建议你

  • 尽可能避免基于百分比的测量。默认情况下,所有测量都将采用与密度无关的像素,这应该适用于大多数用例。
  • ActionBar 通常是一个固定元素,它不会根据屏幕高度增加它的大小。因此,即使您放置自定义视图,也不必保持动态高度。

详细了解 layouts here