滚动工具栏无法在Kitkat上运行

时间:2017-03-24 14:37:13

标签: android toolbar

这是我的主要布局:



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

<!--
  ~ Copyright (c) - Software developed by iClaude.
  -->

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

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

        <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:elevation="4dp">

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

            <android.support.design.widget.TabLayout
                android:id="@+id/sliding_tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/MioStileTabLayout"
                app:tabMode="scrollable" />

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

        <!-- The main content view -->
        <RelativeLayout
            android:id="@+id/main_rlUpdatingDatabase"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="visible" >

            <ProgressBar
                android:id="@+id/main_pbUpdatingDatabase"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="false"
                android:layout_centerInParent="true"
                android:layout_centerVertical="false"
                android:visibility="visible" />

            <TextView
                android:id="@+id/main_tvUpdatingDatabase"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="false"
                android:layout_below="@id/main_pbUpdatingDatabase"
                android:layout_centerHorizontal="false"
                android:layout_centerInParent="true"
                android:layout_centerVertical="false"
                android:text="@string/intro_updatingDatabase"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:visibility="visible"
                android:textColor="@color/text_secondary" />

        </RelativeLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:visibility="invisible"
            android:layout_marginTop="8dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            app:fabSize="normal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_content_new"
            android:layout_gravity="bottom|end"
            app:elevation="6dp"
            app:pressedTranslationZ="6dp"
            android:layout_marginRight="@dimen/fab_margin_right"
            android:layout_marginEnd="@dimen/fab_margin_right"
            android:layout_marginBottom="@dimen/fab_margin_bottom"
            android:onClick="animateFab"
            app:layout_behavior="com.flingsoftware.personalbudget.app.utility.RidimensionaFABBehavior"/>

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fabFav"
            app:fabSize="normal"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_important"
            android:layout_gravity="bottom|end"
            app:elevation="6dp"
            app:pressedTranslationZ="6dp"
            app:backgroundTint="@color/primary"
            android:layout_marginRight="@dimen/fab_margin_right"
            android:layout_marginEnd="@dimen/fab_margin_right"
            android:layout_marginBottom="@dimen/fab_margin_bottom"
            android:onClick="launchFav"
            android:alpha="0" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fabMic"
            app:fabSize="normal"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_action_mic"
            android:layout_gravity="bottom|end"
            app:elevation="6dp"
            app:pressedTranslationZ="6dp"
            app:backgroundTint="@color/primary"
            android:layout_marginRight="@dimen/fab_margin_right"
            android:layout_marginEnd="@dimen/fab_margin_right"
            android:layout_marginBottom="@dimen/fab_margin_bottom"
            android:onClick="launchVocRec"
            android:alpha="0" />

        <android.support.design.widget.FloatingActionButton
            android:id="@+id/fabAgg"
            app:fabSize="normal"
            android:visibility="gone"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_content_new"
            android:layout_gravity="bottom|end"
            app:elevation="6dp"
            app:pressedTranslationZ="6dp"
            app:backgroundTint="@color/primary"
            android:layout_marginRight="@dimen/fab_margin_right"
            android:layout_marginEnd="@dimen/fab_margin_right"
            android:layout_marginBottom="@dimen/fab_margin_bottom"
            android:onClick="aggiungi"
            android:alpha="0" />

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

    <!-- The navigation drawer -->

    <android.support.design.widget.NavigationView
        android:id="@+id/navigation_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <include
                android:id="@+id/navigation_drawer_header_include"
                layout="@layout/header" />

            <ListView
                android:id="@+id/left_drawer"
                android:layout_below="@id/navigation_drawer_header_include"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:choiceMode="singleChoice"
                android:divider="@android:color/transparent"
                android:dividerHeight="0dp"
                android:background="@color/nav_drawer_sfondo" />

        </RelativeLayout>

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

</android.support.v4.widget.DrawerLayout>
&#13;
&#13;
&#13;

使用ViewPager我加载一个包含ExpandableListview(扩展ListView)的Fragment。 在API 19 Kitkat上,当我滚动列表时,工具栏不会滚动进出显示。 在API 21上,一切正常。 如何解决这个问题?

谢谢。

1 个答案:

答案 0 :(得分:2)

ListView不支持API 21之前的嵌套滚动:在API 21中引入嵌套滚动之前,框架视图中不存在API,并且嵌套滚动CoordinatorLayout并且AppBarLayout依赖。