android - 使用坐标布局 ListView 仅显示预览中的第一项

标签 android listview

我正在使用带有 nestedscrollview 和坐标布局的 ListView ,但是当我在设计布局预览中看到它显示 ListView 的第一项时,而且当我运行应用程序时它显示第一项,以下是我的 XML 任何人都可以告诉什么是问题

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

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbarsubcat"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
            app:layout_collapseMode="pin"
            />



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

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


            <ListView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/lvsubcategory"
                android:divider="#ffffff"
                android:dividerHeight="10dp"

                />


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



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

最佳答案

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

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbarsubcat"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:layout_scrollFlags="scroll|enterAlways" />


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


    <ListView
        android:id="@+id/lvsubcategory"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:divider="#ffffff"
        android:dividerHeight="10dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />


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

关于android - 使用坐标布局 ListView 仅显示预览中的第一项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34945367/

相关文章:

java - ViewRootImpl : ViewPostImeInputStage processPointer 0 on OnItemClick of Listview in android

android - 我们可以在 android 中播放 .vtt 文件以获得字幕吗?

java - 多行文本。 libgdx

android - 使用 Ant 构建已签名和未签名的版本

android - 不带滚动条的 ListView 在 ScrollView 中使用

android - 如何使用 RecyclerView 显示空 View ?

android - 成就客户端不显示解锁弹出窗口

android - React Native map 编译错误 debugJavaWithJavac

asp.net - 有谁知道在 asp.net ListView 中隐藏列的方法?

android - 为什么我的 ListView 只显示第一项?