我正在使用Lollipop和AppCompat-v7库中引入的新添加的工具栏.我按照本指南设置了工具栏我注意到当你调用一些会调出上下文ActionBar的内容(例如突出显示复制/粘贴的文本)时,它会将工具栏向下推到页面上.您可以在页面底部的图像中看到我在说什么:
所以,基本上,我这样设置它.我在xml文件中定义了工具栏,我使用包含标签:
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"/>
Run Code Online (Sandbox Code Playgroud)
然后,我在我的视图中实例化它:
<LinearLayout
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"
android:orientation="vertical"
android:id="@+id/root"
tools:context=".MainActivity">
<include
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<!-- Rest of view -->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在代码中,我这样设置:
// On Create method of activity:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Run Code Online (Sandbox Code Playgroud)
有没有人知道怎么做才能让Contextual ActionBar超越工具栏?

android android-appcompat android-5.0-lollipop android-toolbar