【发布时间】:2014-12-14 02:56:03
【问题描述】:
我正在使用 Lollipop 和 AppCompat-v7 库中引入的新添加的工具栏。我在设置工具栏时关注this guide,我注意到当您调用一些会调出上下文操作栏(例如突出显示文本以进行复制/粘贴)时,它会将工具栏向下推到页面上。你可以在页面底部的图片中看到我在说什么:
所以,基本上,我是这样设置的。我在包含标签的 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"/>
然后,我在我的视图中实例化它:
<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>
在代码中,我是这样设置的:
// On Create method of activity:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
有谁知道如何使 Contextual ActionBar 超越工具栏?
【问题讨论】:
-
您的活动使用什么主题?
-
大卫,我刚刚点击了链接,它似乎对我有用。
标签: android android-5.0-lollipop android-appcompat android-toolbar