2016-11-21 72 views
0

我有定義爲nativescript XML視圖如下:Nativescript GridLayout的包裹通過滾動型

<Page 
xmlns="http://schemas.nativescript.org/tns.xsd" 
xmlns:menu="components/menu" 
xmlns:header="components/header" 
loaded="loaded"> 
<header:header /> 
<StackLayout orientation="vertical"> 
<ScrollView> 
    <GridLayout rows="auto,auto,auto,auto" cols="auto,auto" > 
     <Image  row="0" colSpan="2" src="~/img/tap.png" tap="takePicture"/> 
     ... 
     <TextField row="2" col="1" horizontalAlignment="right" /> 
     <Button  row="3" colSpan="2" text="UPLOAD" /> 
    </GridLayout> 
</ScrollView> 
<menu:menu /> 
</StackLayout> 
</Page> 

的GridLayout的是太大而被包含在一個單一的屏幕上,所以我包裹它滾動型的內部。但是這不起作用:我無法滾動頁面,因此最後的UI元素(如TextField和Button)無法訪問。 我在做什麼錯?我應該在不同的位置插入ScrollView標籤嗎?

+0

作爲您的GridLayout的一個附註,您應該使用列而不是cols –

回答

0

嘗試將您的GridLayout包裝在StackLayout中。認爲問題可能是ScrollView很難計算它的滾動高度,因爲GridLayout具有「自動」列和行。

<ScrollView> 
    <StackLayout> 
     <GridLayout rows="auto,auto,auto,auto" cols="auto,auto" > 
      <Image  row="0" colSpan="2" src="~/img/tap.png" tap="takePicture"/> 
      ... 
      <TextField row="2" col="1" horizontalAlignment="right" /> 
      <Button  row="3" colSpan="2" text="UPLOAD" /> 
     </GridLayout> 
    </StackLayout> 
</ScrollView>