首页 > 解决方案 > 如何在 nativescirpt radlistview 上获取固定标题和滚动列表项

问题描述

我的示例代码在这里。问题是当我滚动列表标题时会消失,它应该固定在适当的位置。根据我的要求。

        <lv:RadListView.headerItemTemplate>
            <GridLayout rows="auto" columns="*,*,*,*" borderWidth=".01" borderColor="#004C97" padding='5' class="bg fc4" fontWeight="bold">
                <Label text="Date" fontSize="12" col='0' fontWeight="bold" textAlignment="left" />
                <Label text="Category" col='1' fontSize="12" fontWeight="bold" verticalAlignment="center" textAlignment="left" />
                <Label text="Amount" fontSize="12" col='3' fontWeight="bold" textAlignment="right" />
                <Label text="Comments" col="2" fontSize="12" fontWeight="bold" verticalAlignment="center" textAlignment="left" />
            </GridLayout>
        </lv:RadListView.headerItemTemplate>

        <lv:RadListView.itemTemplate>
            <GridLayout rows="auto" columns="*,*,*,*" borderWidth=".01" borderColor="#004C97" padding='10' class="fc4" fontWeight="bold">
                <Label text="{{date}}" fontSize="14" col='0' fontWeight="bold" textAlignment="left" />
                <Label text="{{expenseCat}}" col='1' fontSize="14" fontWeight="bold" verticalAlignment="center" textAlignment="left" />
                <Label text="{{expenseAmount}}" fontSize="14" col='3' fontWeight="bold" textAlignment="right" />
                <Label text="{{comments}}" col="2" fontSize="14" fontWeight="bold" verticalAlignment="center" textAlignment="left" />
            </GridLayout>
        </lv:RadListView.itemTemplate>

    </lv:RadListView>

标签: androidnativescript

解决方案


将 GridLayout 与rows="auto,*". 将您的标题布局(第 0 行)放在 ListView(第 1 行)上方,使其保持固定。


推荐阅读