android - 如何在嵌套滚动、ConstraintLayout 中设置ListView 滚动?

标签 android android-constraintlayout android-nestedscrollview

我在 ListView 上添加了我的项目。 我可以使用 NestedScroll 的 滚动,但我无法显示我的 listView 的 项目,我只能显示 3 个。

我想要一个类似 Twitter 个人资料页面的设计

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".ProfileFragment">

    <android.support.design.widget.AppBarLayout...>

        <android.support.design.widget.CollapsingToolbarLayout
            ...>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbarProfile"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

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

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

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:fillViewport="true">

        <ListView
            android:id="@+id/listViewProfile"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical">
        </ListView>

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

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

最佳答案

启用listviewnestedScrolling:

<ListView
     android:id="@+id/listViewProfile"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:nestedScrollingEnabled="true" \\add this line
     android:scrollbars="vertical">
</ListView>

关于android - 如何在嵌套滚动、ConstraintLayout 中设置ListView 滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55798633/

相关文章:

java - 多个 Activity/fragment 的自定义对话框界面

android - 如何使 MVRX View 模型与 dagger2 一起工作?

android - 嵌套约束布局?这是一种不好的做法吗?

android - RecyclerView notifyDataSetChanged() 在没有 ANR 的情况下卡住 UI

android - 实现应用程序 :hideOnScroll for BottomAppBar in Android

android - 在电子邮件 : android. 中发送多个附件 intent.extra.STREAM 预期 Parcelable

java - Admob - 没有广告可显示

android - 除非重叠 TextView ,否则是否可以使图标在约束布局中居中

android - ConstraintLayout 中 CardView 上的阴影未显示

android - RecyclerView Laggy inside NestedScrollView/LinearLayout