2016-09-17 65 views
0

我有一個TextView在GridLayout中,並設置爲獲取最大可用高度。這樣可行。獲取TextView滾動

但是,如果用戶將新行按下到TextView的底部等等 - TextView光標離開屏幕的底部而不是滾動TextView。

我怎樣才能讓TextView滾動。

+0

你可以使用滾動型 - https://docs.nativescript.org/cookbook/ui/scroll-view並添加它內部的TextView,但是如果你能給我們示例代碼,問題可以在本地複製,那麼我們將能夠爲你的案例提供更好的解決方案。 –

+0

這裏是xml文件。 '。沒有滾動。 – dashman

+0

是iOS還是Android? –

回答

1

iOSTextVie如果您在其中設置大文本,w應默認爲可滾動。 但是,對於Android,您可以使用ScrollView並將StackLayout用於其中的主容器。對於進一步的幫助,你可以查看下面的附件中的例子:

主page.xml

<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo"> 
    <GridLayout columns="*" rows="auto,*"> 
    <GridLayout row="0" col="0" columns="auto,*" rows="auto"> 
     <Label text="header" row="0" col="0" /> 
    </GridLayout> 

    <GridLayout row="1" col="0" columns="auto,*" rows="auto"> 
     <Label text="Note" row="0" col="0" /> 
     <ScrollView orientation="vertical" row="1" col="0" height="300" width="300" backgroundColor="green"> 
      <StackLayout orientation="vertical" class="scroll-menu" backgroundColor="red"> 
       <TextView text="" hint="Enter text..." /> 
      </StackLayout> 
     </ScrollView> 
    </GridLayout> 
    </GridLayout> 
</Page> 
+0

謝謝 - 這工作!它也可以在沒有在ScrollView中顯式設置高度和寬度的情況下工作 - 但是對於GridLayout,您必須將行設置爲* - 這是有道理的。 – dashman