Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Recyclerview未在Android 6中显示所有项目_Android_Android Layout_Android Recyclerview - Fatal编程技术网

Recyclerview未在Android 6中显示所有项目

Recyclerview未在Android 6中显示所有项目,android,android-layout,android-recyclerview,Android,Android Layout,Android Recyclerview,我的recyclerview显示了Android 4-5中的所有项目,但没有显示Android 6中的所有项目。我尝试调试它,但在xml或adpater文件中找不到任何内容。有人有同样的问题吗 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.an

我的recyclerview显示了Android 4-5中的所有项目,但没有显示Android 6中的所有项目。我尝试调试它,但在xml或adpater文件中找不到任何内容。有人有同样的问题吗

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="fill_parent"
    tools:context="com.app.Activities.ProductActivity"
    android:orientation="vertical">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:elevation="4dp"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:theme="@style/ToolBarStyle"
    android:gravity="center_horizontal"/>


<ScrollView
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:fillViewport="true"
    android:fitsSystemWindows="true"
    android:isScrollContainer="true"
    android:scrollbars="none">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/productsRV"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    </LinearLayout>
</ScrollView>


滚动视图
中嵌套
回收视图
,这是一件必须小心完成的事情

尝试删除
滚动视图
,只需使用
回收视图

像这样

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="fill_parent"
    tools:context="com.app.Activities.ProductActivity"
    android:orientation="vertical">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:elevation="4dp"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:theme="@style/ToolBarStyle"
    android:gravity="center_horizontal"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/productsRV"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    </LinearLayout>


如果它不起作用,请发布代码的其余部分。

滚动视图中嵌套
RecyclerView
,这是一件必须小心完成的事情

尝试删除
滚动视图
,只需使用
回收视图

像这样

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="fill_parent"
    tools:context="com.app.Activities.ProductActivity"
    android:orientation="vertical">

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:elevation="4dp"
    android:layout_gravity="center"
    android:layout_width="match_parent"
    android:layout_height="56dp"
    android:background="?attr/colorPrimary"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/AppTheme.PopupOverlay"
    app:theme="@style/ToolBarStyle"
    android:gravity="center_horizontal"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/productsRV"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    </LinearLayout>


如果它不起作用,请发布其余代码。

谢谢,它在Android 6中通过用嵌套的scrollview替换scrollview开始工作。

谢谢,它在Android 6中通过用嵌套的scrollview替换scrollview开始工作。

试试这个,它会对你起作用

<ScrollView 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="fill_parent"
    tools:context="com.app.Activities.ProductActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

       <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:elevation="4dp"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:theme="@style/ToolBarStyle"
        android:gravity="center_horizontal"/>  

        <android.support.v7.widget.RecyclerView
          android:id="@+id/productsRV"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="16dp"
          app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
     </LinearLayout>
</ScrollView>

试试这个,它会对你有用

<ScrollView 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="fill_parent"
    tools:context="com.app.Activities.ProductActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="8dp">

       <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:elevation="4dp"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"
        app:popupTheme="@style/AppTheme.PopupOverlay"
        app:theme="@style/ToolBarStyle"
        android:gravity="center_horizontal"/>  

        <android.support.v7.widget.RecyclerView
          android:id="@+id/productsRV"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginTop="16dp"
          app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 
     </LinearLayout>
</ScrollView>


删除
滚动视图
。一切正常。请提供viewRemove android:layout_weight=“1”的屏幕截图,如果您想使用它,scrollview的
高度必须是
0dp
。使用NestedScrollView而不是scrollview,设置android:isScrollContainer=“false”删除
scrollview
。一切正常。请提供viewRemove android:layout_weight=“1”的屏幕截图,如果您想使用它,scrollview的
height
必须是
0dp
。使用NestedScrollView而不是scrollview,设置android:isScrollContainer=“false”scrollview是必需的,因为上面的recyclerview有两个TextView和ImageView。我尝试删除scrollview,但仍然没有在Android 6中显示所有项目。记住,它只需要在Android 6scrollview中不工作,因为上面的recyclerview有两个TextView和ImageView。我尝试删除scrollview,但仍然没有在Android 6中显示所有项目。记住它在Android 6中唯一不起作用的地方就是不需要添加嵌套的scrollview。只需使用回收器视图。无需添加嵌套的滚动视图。只需使用回收器视图。