ListView в BottomSheet не прокручивается

Написание для Android API 23 и выше (тестирование на API 24 и 25).

Я написал XML, который пытается поместить ListView внутрь BottomSheet. Когда я пытаюсь прокрутить свой ListView (в любом направлении), прокручивается BottomSheet, а не ListView.

Я безуспешно пробовал следующий обходной путь:

ListView в нижнем листе

Мой файл макета XML выглядит следующим образом:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <Button
                android:id="@+id/refresh_button"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:onClick="onButtonPress"
                android:text="@string/refresh_button" />

            <RelativeLayout
                android:id="@+id/map_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1">

                <fragment
                    android:id="@+id/map_fragment"
                    android:name="com.google.android.gms.maps.MapFragment"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

                <android.support.design.widget.FloatingActionButton
                    android:id="@+id/floating_action_button"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignParentRight="true"
                    android:layout_marginBottom="15dp"
                    android:layout_marginRight="15dp"
                    android:clickable="true"
                    app:srcCompat="@android:drawable/ic_menu_mylocation" />

            </RelativeLayout>

        </LinearLayout>

    </RelativeLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/bottom_sheet"
        android:layout_width="match_parent"
        android:layout_height="400dp"
        android:background="?android:attr/windowBackground"
        android:clipToPadding="true"
        android:fillViewport="true"
        app:layout_behavior="android.support.design.widget.BottomSheetBehavior">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/colorPrimary"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/textView11"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:padding="16dp"
                    android:text="Stations"
                    android:textColor="#ffffff"
                    android:textSize="24sp" />

            </LinearLayout>

            <com.example.nicsutherland.stationfinder.Adapters.BottomSheetListView
                android:id="@+id/list_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</android.support.design.widget.CoordinatorLayout>

Мой класс Java содержит следующий код в методе onCreate():

View bottomSheet = findViewById( R.id.bottom_sheet );
mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
mBottomSheetBehavior.setPeekHeight(300);

Как я могу добраться до точки, в которой мой ListView будет прокручиваться независимо от моего BottomSheet?


person Nic2352    schedule 08.03.2018    source источник


Ответы (2)


попробуй это :

com.example.nicsutherland.stationfinder.Adapters.BottomSheetListView
                android:id="@+id/list_view"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:nestedScrollingEnabled="true"\\insert this line
/>
person mohammadReza Abiri    schedule 23.10.2018

Установите BottomSheetDialog Cancelable false и CanceledOnTouchOutside true.

 bottomSheetDialog.setCancelable(false);


 bottomSheetDialog.setCancelable(false);

нижний листдиалог.setCanceledOnTouchOutside (истина);

person X Body    schedule 21.12.2020