Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.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
Android actionbar.setHideOffset()导致强制关闭_Android_Android Actionbar Compat_Android Toolbar - Fatal编程技术网

Android actionbar.setHideOffset()导致强制关闭

Android actionbar.setHideOffset()导致强制关闭,android,android-actionbar-compat,android-toolbar,Android,Android Actionbar Compat,Android Toolbar,我使用这段代码使用AppCompact v7实现了新的actionbar,一切都很好: supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.activity_main); mActionbar = getSupportActionBar(); mActionbar.setHideOffset(10); 但为了使用新的动画导航抽屉指示器,我不得不使用xml工具栏。 这是我的

我使用这段代码使用AppCompact v7实现了新的actionbar,一切都很好:

supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
setContentView(R.layout.activity_main);
mActionbar = getSupportActionBar();
mActionbar.setHideOffset(10);
但为了使用新的动画导航抽屉指示器,我不得不使用xml工具栏。 这是我的新活动\u主xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

<android.support.v4.widget.DrawerLayout
    android:id="@+id/MainMenu_drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
<RelativeLayout
    android:id="@+id/contents"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
</RelativeLayout>
<RelativeLayout
    android:id="@+id/list"
    android:layout_height="match_parent"
    android:layout_width="match_parent">
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
<android.support.v7.widget.Toolbar
        android:id="@+id/content_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        style="@style/Actionbar"/>
</RelativeLayout>
强制关闭发生在最后一行

它在logcat中没有显示任何错误,只是强制关闭

抱歉英语不好:)

将其更改为

   getSupportActionBar().setHideOffset(0);
设置动作栏的当前隐藏偏移

动作栏的当前隐藏偏移量是动作开始的距离 该条当前以像素为单位滚动到屏幕外。有效范围为0 (完全可见)到操作栏的当前测量高度(完全可见 无形的)


但我想使用这种方法在内容滚动时平滑地隐藏动作栏(在API<21上)。
   getSupportActionBar().setHideOffset(0);