【问题标题】:Native Script ScrollView and AbsoluteLayout原生脚本 ScrollView 和 AbsoluteLayout
【发布时间】:2015-10-23 02:45:23
【问题描述】:

我是 NS 的新手,我有一个项目。我想要一个 Button 浮动在 ScrollView 中。

<ScrollView>
     <StackLayout orientation="vertical">
           <AbsoluteLayout >
               <Button top="0" left="0" right="0" text="Test" style="font-size: 10; margin:5; " />
            </AbsoluteLayout>
                <Label text="Trending Now: " cssClass="trending-label" />
                <Repeater items="{{ categories }}">
                    <Repeater.itemTemplate>
                        .
                        .
                        .
                    </Repeater.itemTemplate>
                </Repeater>
            </StackLayout>
        </ScrollView>

但它不起作用。按钮也在滚动。我希望 Button 浮动在 ScrollView 上。谢谢你。

【问题讨论】:

    标签: scrollview absolutelayout nativescript


    【解决方案1】:

    按钮与其他项目一起滚动的原因是所有内容都位于 ScrollView 中。为了只有 Label 和 Repeater 滚动,Button 应该放在它的外面。

    我注意到的另一件事是,在 Button 上,同时应用了左右对齐,这可能会导致问题。

    我做了一个浮动按钮的可能实现,你可以查看here

    【讨论】:

    • 感谢您的回复。我尝试了您的建议,它有效,按钮浮动但无法滚动..
    • 滚动取决于您在“类别”集合中有多少项目。您可以尝试添加更多项目,使其超出屏幕尺寸。
    • 我尝试添加更多项目,但仍然无法滚动:(
    • 你能否提供更多关于设备或模拟器的信息,你正在测试和代码,所以我可以尝试模拟它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-06
    • 2020-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多