ListView не работает под Relative- и LinearLayout - PullRequest
0 голосов
/ 01 марта 2020

У меня проблема с прокруткой списка, который находится внутри LinearLayout (внутри родственника). (в других видах деятельности прокрутка работает, но у меня есть только один LinearLayout) Могу ли я использовать его, как показано ниже? Или мне нужно уменьшить количество макетов?

Я пытался установить функции прокрутки вручную.

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
        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=".post_watch"
        android:background="#979797">

    <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:theme="@style/AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/PopupOverlay"/>

        <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbarAlwaysDrawVerticalTrack="true"
                android:nestedScrollingEnabled="true">

            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_above="@+id/commenter"
                    android:layout_below="@+id/viewer"
                    android:layout_marginTop="0dp"
                    android:layout_marginBottom="0dp"
                    android:nestedScrollingEnabled="true"
                    android:scrollbarAlwaysDrawVerticalTrack="true">

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

        </RelativeLayout>

    </com.google.android.material.appbar.AppBarLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

1 Ответ

0 голосов
/ 01 марта 2020

Найденное решение (смените координатор на расположение ящика):

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
        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=".post_watch"
        android:background="#979797">

    <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:theme="@style/AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/PopupOverlay"/>

        <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scrollbarAlwaysDrawVerticalTrack="true"
                android:nestedScrollingEnabled="true">

            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_above="@+id/commenter"
                    android:layout_below="@+id/viewer"
                    android:layout_marginTop="0dp"
                    android:layout_marginBottom="0dp"
                    android:nestedScrollingEnabled="true"
                    android:scrollbarAlwaysDrawVerticalTrack="true">

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

        </RelativeLayout>

    </com.google.android.material.appbar.AppBarLayout>

</androidx.drawerlayout.widget.DrawerLayout>```
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...