1

I have this code in main-page.xml:

<GridLayout rows="auto, *">

  <Label text="Title" class="title" row="0" />

  <ListView id="listView" items="{{ listItems }}" row="1">

    <ListView.itemTemplate>
      <StackLayout>
        <Button text="{{ name }}" tap="dd" />
      </StackLayout>
    </ListView.itemTemplate>

  </ListView>

</GridLayout>

When I scroll the title stick to the top (stay and don't move), is there is a way to make it behave normally ?

3
  • Are the rest of the elements scrolling underneath the title? Is the amount of items longer than the screen of your testing device? Commented Jul 23, 2016 at 14:56
  • Yes the elements scroll underneath the title, and Yes the amount of items longer than the screen of the device. Commented Jul 23, 2016 at 15:10
  • I think this is the expected behaviour. Add another set of title and list and scroll to see what happens. It should be similar to what you see when scrolling down your Instagram feed, author stays on top as long as the displayed content belongs to this author. Commented Jul 23, 2016 at 15:27

2 Answers 2

1

I found a cleaner solution using : https://docs.nativescript.org/cookbook/ui/repeater

<ScrollView>

  <StackLayout>

    <Label text="Title" class="title" />

    <Repeater id="listItems" items="{{ listItems }}">

      <Repeater.itemTemplate>
        <StackLayout>
          <Button text="{{ name }}" tap="loadGuide" />
        </StackLayout>
      </Repeater.itemTemplate>

   </Repeater>

 </StackLayout>

Sign up to request clarification or add additional context in comments.

Comments

0

This is definitely the expected behavior when placing a Label at a row of a GridLayout which is set to auto. What you want to achieve can be done but will require additional implementations for example like this (No boring ActionBar) third party Android library. What you can do is either implement the same using pure JavaScript/TypeScript directly in your app (by managing the size of the ActionBar) or create a custom NativeScript plugin that uses the mentioned android library.

One of the many beauties of NativeScript is that 100% of the native iOS and Android APIs are accessible meaning anything that is achievable in an native iOS or Android app is achievable in {N}.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.