当滚动时尝试隐藏工具栏时无法滚动RecyclerView

时间:2018-02-13 21:19:52

标签: android scroll android-recyclerview

我尝试从this教程中隐藏工具栏 滚动列表 它在我的一个项目中工作,但当我在另一个项目中尝试时,RecycleView 根本不滚动
而不是RecycleView,工具栏可滚动
我的意思是我可以通过滚动工具栏隐藏工具栏(向下滑动工具栏

app_bar_main.xml:

.vscode

content_main.xml:

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="bearing.chavosh.com.bearingdemo.Activity.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/app_bar_background"
        android:theme="@style/AppTheme.AppBarOverlay"
        android:background="#f5f5f5">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_scrollFlags="scroll|enterAlways"
            android:theme="@style/AppTheme.AppBarOverlay"
            app:theme="@style/ThemeOverlay.AppCompat.Light"
            app:popupTheme="@style/AppThemePopupOverlayLight">


            <bearing.chavosh.com.bearingdemo.Utility.MyTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="ارسال موقعیت"
                android:textSize="17sp"
                android:textColor="#000000"
                android:layout_gravity="center"
                android:id="@+id/toolbar_title" />

        </android.support.v7.widget.Toolbar>

        <View
            android:layout_width="match_parent"
            android:layout_height="0.25dp"
            android:id="@+id/viewShadow"
            android:background="#BBBBBB"/>

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

    <include layout="@layout/content_main"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_height="match_parent"
        android:layout_width="match_parent" />


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

load_list.xml,包含在上面的源代码中:

<?xml version="1.0" encoding="utf-8"?>
<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"
    android:background="#f5f5f5"
    tools:context="bearing.chavosh.com.bearingdemo.Activity.MainActivity"
    tools:showIn="@layout/app_bar_main">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/llBarsList">

        <include layout="@layout/loads_list"
            android:layout_height="match_parent"
            android:layout_width="match_parent" />

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

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

我没有找到任何答案,我正在研究它一天 任何帮助,请

1 个答案:

答案 0 :(得分:1)

它无法正常工作,因为你通过包含布局搞砸了。您已将load_list xml包含在content_main xml中,但loads_list xml包含TabLayout一些ViewViewPager以及您放入AppBarLayout <include layout="@layout/loads_list"/> 1}} AppBarLayout

TabLayout可以包含ViewPager,但app_main会让事情变得混乱。然后在AppBarLayout内你有另一个TabLayout。因此,app_main直接放入Toolbar ViewPager以下的CoordinatorLayout xml。并在type: Loadbalancer内包含async。你可以摆脱其中一个xml,这是不必要的。