【问题标题】:How can I set ListView's scroll in NestedScroll, ConstraintLayout?如何在 NestedScroll、ConstraintLayout 中设置 ListView 的滚动?
【发布时间】:2019-04-22 17:45:24
【问题描述】:

我在ListView 上添加了我的项目。 我可以使用 NestedScroll's 滚动,但我无法显示我的 listView's 项目,我只能显示 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>

【问题讨论】:

    标签: android android-constraintlayout android-nestedscrollview


    【解决方案1】:

    启用nestedScrollinglistview

    <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>
    

    【讨论】:

      猜你喜欢
      • 2020-12-08
      • 2012-10-16
      • 1970-01-01
      • 1970-01-01
      • 2014-02-17
      • 1970-01-01
      • 2023-03-26
      • 1970-01-01
      • 2019-02-05
      相关资源
      最近更新 更多