滚动工具栏不工作在Android使用框架布局

问题描述:

我有一些麻烦让滚动工具栏与我的程序一起工作。现在,工具栏就好像我没有实现任何滚动的东西。我的活动XML是这样的:滚动工具栏不工作在Android使用框架布局

<?xml version="1.0" encoding="utf-8"?> 

<android.support.v7.widget.RecyclerView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/matchRV" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 
    </android.support.v7.widget.RecyclerView> 

我知道这可能将是愚蠢的东西,但我做不到:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/activity_summoner_search" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.kevin.leagueoflegendshelper.SummonerSearchActivity"> 


    <android.support.v4.widget.DrawerLayout 
     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:id="@+id/drawer_Layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true"> 

     <android.support.design.widget.CoordinatorLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <android.support.design.widget.AppBarLayout 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:id="@+id/appBarLayout"> 

       <android.support.design.widget.CollapsingToolbarLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

        <android.support.v7.widget.Toolbar 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:id="@+id/toolBar" 
         android:background="@color/colorPrimary" 
         android:elevation="4dp" 
         android:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
         app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
         app:layout_collapseMode="parallax"> 

         <TextView 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="placeholder" 
          android:id="@+id/toolBar_Title" 
          style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title" 
          android:layout_gravity="start" 
          app:layout_collapseMode="parallax" 
          android:fitsSystemWindows="true"/> 
        </android.support.v7.widget.Toolbar> 

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

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



      <FrameLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:id="@+id/frameLayout" 
       app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Search for a summoner to begin" 
        android:textSize="36dp" 
        android:paddingTop="10dp" 
        android:id="@+id/searchLabel"/> 
      </FrameLayout> 

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

     <android.support.design.widget.NavigationView 
      android:id="@+id/nav_View" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:fitsSystemWindows="true" 
      android:paddingTop="20dp" 
      app:menu="@menu/main_drawer_layout"> 

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


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



</RelativeLayout> 

我与具有以下布局的片段填充的FrameLayout因为我的生活似乎能够得到它的工作。任何帮助,将不胜感激。

+0

检查我的回答如下... – FAT

+0

运会自动得到通知......当一个答案来了......没必要大惊小怪@FerdousAhamed – rafsanahmad007

添加属性app:layout_scrollFlags="scroll|enterAlways"Toolbar

试试这个:

<android.support.v7.widget.Toolbar 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/toolBar" 
    android:background="@color/colorPrimary" 
    android:elevation="4dp" 
    android:theme="@style/ThemeOverlay.AppCompat.ActionBar" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    app:layout_scrollFlags="scroll|enterAlways" 
    app:layout_collapseMode="parallax"> 
+0

谢谢,这是我错过的! – KevinCamacho