上下文操作栏未覆盖我的工具栏 [英] Contextual action bar does not overlay my toolbar

查看:71
本文介绍了上下文操作栏未覆盖我的工具栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个活动,并将工具栏设置为我位于底部的操作栏.

I have created an activity and set toolbar as the actionbar which i have positioned at the bottom.

在该活动中,我有一个包含一些数据的列表视图.

Inside that activity, I have a listview that contain some data.

问题是,当我长按列表项时,上下文操作栏会显示在顶部,而不是覆盖我的工具栏,该工具栏位于底部.

Problem is, when I long press a list item, contextual action bar appears at the top instead of overlaying my toolbar which is positioned at the bottom.

我的活动主题

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Base application theme. -->
<style name="myActivityTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="android:windowActionModeOverlay">true</item>
</style>

我的工具栏

<android.support.v7.widget.Toolbar
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:id="@+id/toorbar"
    android:background="@android:color/white"
    android:layout_gravity="bottom">
</android.support.v7.widget.Toolbar>

我的活动

protected void onCreate(Bundle savedInstanceState){
    ToolBar toolbar =(ToolBar) findViewById(R.id.toolbar)
    setSupportActionBar(toolbar)
}

我应该怎么做才能使CAB覆盖我的工具栏?

What should i do to make CAB overlay my toolbar?

编辑

这是我班上的onCreateActionMode方法,可以处理长时间的点击

This is onCreateActionMode method in my class that handle long clicks

private class Selector implements AbsListView.MultiChoiceModeListener{

    @Override
    public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
        mode.getMenuInflater().inflate(R.menu.my_activity_menu,menu);
        toolbar.setVisibility(View.VISIBLE);
        return true;
    }

推荐答案

由于我的工具栏位于活动的底部,因此解决方案是制作自己的上下文操作栏来覆盖它.

Since my toolbar was at the bottom of the activity, solution was to make my own contextual action bar that will overlay it.

下面的这个项目使我有了一个良好的开端.

This project below gave me a head start.

https://github.com/afollestad/material-cab

这篇关于上下文操作栏未覆盖我的工具栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆