I have been attempting to implement a vertical scroll for a list view, but I am facing an issue where all the list view items are displayed even if they exceed the phone's screen size.
This is the code snippet I have been using:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px">
<GridLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:rowCount="6"
android:columnCount="1"
android:orientation="vertical"
android:id="@+id/myGridID">
<!-- other controls like TextView, EditBox, other Grid layouts -->
<ListView
android:layout_row="4"
android:layout_column="0"
android:isScrollContainer="true"
android:choiceMode="singleChoice"
android:scrollbarSize="100px"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/myListId" />
<!-- other controls like TextView, EditBox, other Grid layouts -->
</GridLayout>
</LinearLayout>
My expectation was that when the height of the list items exceeded 100px (the value set in android:scrollbarSize), the vertical scroll would become active. However, this is not happening as intended.
I then tried the following code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="25px"
android:minHeight="25px">
<GridLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:rowCount="6"
android:columnCount="1"
android:orientation="vertical"
android:id="@+id/myGridID">
<!-- other controls like TextView, EditBox, other Grid layouts -->
<ScrollView
a:visibility="visible"
xmlns:a="http://schemas.android.com/tools"
android:scrollbars="vertical"
android:visibility="visible"
android:layout_height="150px"
android:layout_row="4"
android:layout_column="0">
<ListView
android:isScrollContainer="true"
android:choiceMode="singleChoice"
android:scrollbarSize="100px"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/myListId" />
</ScrollView>
<!-- other controls like TextView, EditBox, other Grid layouts -->
</GridLayout>
</LinearLayout>
Wrapping the list view inside a ScrollView did create a vertical scroll, however, only one list item was shown at a time. I was hoping to see at least three items from the list view before needing to scroll through the rest.
Ideally, I would like to achieve the vertical scrolling feature using just the list view without the need for a ScrollView, since it complicates accessing a child from the list. Can someone please guide me on what might be going wrong with implementing the built-in vertical scroll for the Android Xamarin list view?