【问题标题】:nativescript scrollview android doesnt worknativescript scrollview android不起作用
【发布时间】:2018-06-12 19:25:09
【问题描述】:

我的 StackLayout 无法在 scrollView 中滚动时遇到问题。

<Page loaded="loaded" id="main">
<Page.actionBar>
    <ActionBar title="Register">
    </ActionBar>
</Page.actionBar>
<ScrollView orientation="vertical" id="scrollView">
    <StackLayout id="Content">
        <Label id="Lfname" text="First name: " />
        <TextField text="{{ fname }}" id="fname" hint="first name" />

        <Label text="Last name: " />
        <TextField text="{{ lname }}" id="lname" hint="last name" />

        <Label text="E-mail: " />
        <TextField text="{{ email }}" id="email" hint="email" />

        <Label text="Confirm E-mail: " />
        <TextField text="{{ emailConfirm }}" id="emailConfirm" hint="email" />

        <Label text="Password: "/>
        <TextField text="{{ password }}" id="password" secure="true"/>

        <Label text="Confirm Password: "/>
        <TextField text="{{ passwordConfirm }}" id="passwordConfirm" secure="true"/>

        <Button id="register" text="Register" tap="onRegister" class="confirm" />
        <Button id="login" text="Login" tap="onLogin" class="link"/>
    </StackLayout>
</ScrollView>
</Page>

我花了几个小时寻找问题,但找不到。我对 nativescript 很陌生,所以这可能是问题所在。

这是我的包裹:

{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
    "id": "org.nativescript.foodFetish",
    "tns-android": {
        "version": "4.0.1"
    }
},
"dependencies": {
    "nativescript-theme-core": "~1.0.4",
    "tns-core-modules": "^4.1.0"
},
"devDependencies": {
    "babel-traverse": "^6.26.0",
    "babel-types": "^6.26.0",
    "babylon": "6.4.5",
    "lazy": "1.0.11"
}
}

我运行的是 android 4.4.2。

【问题讨论】:

    标签: android nativescript


    【解决方案1】:

    这应该可以,至少它可以在我的设备上运行。遇到问题时不要犹豫创建 Playground,重现错误会更容易(here is one for your code)。请注意,仅当要显示的内容多于屏幕大小时,ScrollView 才会滚动,因此如果您的屏幕大于 ScrollView 内的内容,您将看不到任何滚动效果。

    【讨论】:

    • 感谢您的回复。它在操场上也对我有用。但是当我在 Visual Studio Code 的调试器中运行它时。它不是。我确实在 app-root.xml 的框架中有视图。似乎 StackLayout 并不关心其中的内容。当我在内容上调用“getMeasuredHeight()”时,它保持屏幕大小。我认为它只是不会让它呈现在我的屏幕之外,所以滚动视图没有任何东西可以滚动到。 image。这是我在手机中看到的视图。
    【解决方案2】:

    我发现了问题。似乎我将“#Content”的高度设置为“100%”。愚蠢的错误,感谢您的回复。

    【讨论】:

      猜你喜欢
      • 2015-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-19
      • 2021-10-21
      • 2018-04-23
      相关资源
      最近更新 更多