ListView not scrolling on Android 7.1.1

Viewed 28

I'm trying to deploy a ListView app on an Android 7.1.1 device. The list view contains enough items to exceed the size of the screen. Any layouting/code combination that I have tried so far has failed - there is no scrolling performed on the device.

Here is the latest layout excerpt:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ListView
        android:id="@+id/list_view"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:scrollbarSize="3dp"
        android:scrollbarStyle="outsideOverlay"
        android:scrollbars="vertical"
        android:scrollingCache="true"
        android:smoothScrollbar="true" />
</LinearLayout>

Any hint would be appreciated.

Edit: The list view is built by an android.widget.ArrayAdapter and an android.R.layout.simple_list_item_activated_1 item layout:

itemsList = findViewById(R.id.list_view);
itemsList.setAdapter(new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_activated_1, new ArrayList<>(...items...)));
itemsList.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
1 Answers

Tip 1: Use match_parent instead of fill_parent

Tip 2: Use RecyclerView. It's much more flexible and modern then ListView.

Tip 3: There is no need for that LinearLayout, if there is just one view in it.

Hope some of these tips will fix your issue.

Related