相关疑难解决方法(0)

使用AppCompat-v7的工具栏和上下文ActionBar

我正在使用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超越工具栏?

工具栏和上下文ActionBar

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

179
推荐指数
5
解决办法
6万
查看次数

按下工具栏的动作模式栏

在我的应用程序中,我正在使用官方文档中解释的工具栏(v7 appcompat 支持库,Theme.Appcompat.Light.NoActionBar, android.support.v7.widget.Toolbar, setSupportActionBar(myToolbar))http : //developer.android.com/training/appbar/index.html

我有一个ExpandableListView,我想在我长按一个项目时实现上下文操作模式。为了实现这一点,我使用: setMultiChoiceModeListener(new MultiChoiceModeListener())。但是这样一来,动作模式栏显示在屏幕顶部,按下Toolbar(我认为是因为系统使用的是普通动作模式,而不是支持动作模式)。我希望它显示在工具栏上。

我试过这个解决方案:

windowActionBarOverlay = true
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

android toolbar android-actionbar actionmode

7
推荐指数
2
解决办法
825
查看次数