[英]Can't scroll RecyclerView, when try to hide toolbar on scrolling
I try to hide toolbar on scrolling list from this tutorial我尝试在本教程中隐藏滚动列表上的工具栏
it works in one of my project, but when i try that in another project RecycleView doesn't scroll at all它适用于我的一个项目,但是当我在另一个项目中尝试时,RecycleView根本不滚动
And instead of RecycleView the toolbar is scrollable !而不是 RecycleView工具栏是可滚动的!
I mean that I can hide toolbar by scrolling toolbar ( slide down and up the toolbar )我的意思是我可以通过滚动工具栏来隐藏工具栏(向下和向上滑动工具栏)
app_bar_main.xml: app_bar_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>
content_main.xml: 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: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>
load_list.xml that include in above source code: load_list.xml 包含在上述源代码中:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#f5f5f5"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:showIn="@layout/content_main">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#f5f5f5"
app:tabIndicatorColor="#0067A5"
app:tabIndicatorHeight="2dp"
app:tabMode="scrollable"
app:tabGravity="center"/>
<View
android:layout_width="match_parent"
android:layout_height="0.25dp"
android:layout_below="@+id/tabs"
android:id="@+id/viewShadow"
android:background="#BBBBBB"/>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/viewShadow"
android:id="@+id/vp_bars_list" />
</RelativeLayout>
I didn't find any answer and I was working on it for one day我没有找到任何答案,我正在研究一天
any help , please任何帮助,请
Its not working properly because you mess things up by including layouts.它无法正常工作,因为您通过包含布局将事情搞砸了。 You have included
load_list
xml in content_main
xml but loads_list
xml contains TabLayout
some View
and ViewPager
and all of that you put inside AppBarLayout
by <include layout="@layout/loads_list"/>
.您已包括
load_list
XML在content_main
XML,但loads_list
XML包含TabLayout
一些View
和ViewPager
和所有的,你把里面的AppBarLayout
通过<include layout="@layout/loads_list"/>
AppBarLayout
can contain TabLayout
but ViewPager
will mess things up. AppBarLayout
可以包含TabLayout
但ViewPager
会把事情搞砸。 And then inside app_main
you have another AppBarLayout
.然后在
app_main
里面你有另一个AppBarLayout
。 So put TabLayout
directly into app_main
xml below Toolbar
.所以把
TabLayout
直接进入app_main
下面的XML Toolbar
。 And include ViewPager
below them inside CoordinatorLayout
.并将
ViewPager
包含在它们下方的CoordinatorLayout
。 You can get rid of one of those xml its unnecessary.您可以摆脱那些不必要的 xml 之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.