创建一个覆盖视图以覆盖整个活动,包括协调器布局中的工具栏

2024-05-02

我想创建一种覆盖类型的布局,以显示在包括工具栏在内的活动上方。我无法使用任何库来执行此操作,因为我编写的所有内容都是自定义的。我可以通过使用以下代码直接将视图添加到装饰视图来实现它:

ViewGroup vg = (ViewGroup)(getWindow().getDecorView().getRootView());
tutorialViewContainer = (RelativeLayout) View.inflate(this, R.layout.layout_simple_overlay, null);
vg.addView(tutorialViewContainer, params);

但这段代码有一个问题,它甚至覆盖了状态栏和导航栏。我只需要覆盖包括工具栏在内的活动空间。

我必须做一些类似于这些帖子的东西 -here https://stackoverflow.com/questions/10216937/how-do-i-create-a-help-overlay-like-you-see-in-a-few-android-apps-and-ics and here https://stackoverflow.com/questions/26348560/making-a-tutorial-coach-mark-overlay-need-help-moving-a-view-based-on-the-pos但问题是我正在使用添加了应用程序栏的协调器布局。所以我无法使视图在工具栏上方可见。

这是 xml 代码。simple_overlay_container是我为叠加添加的视图,但它显示在工具栏下方。

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    android:id="@+id/main_content"
    style="@style/ActivityBaseStyle"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="false"
    tools:context=".activity.BaseAmcatQuestionActivity">
  <android.support.design.widget.AppBarLayout
      android:id="@+id/main.appbar"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:fitsSystemWindows="true"
      android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    <include
        android:id="@+id/toolbar_base_question_activity"
        layout="@layout/toolbar_test_custom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
  </android.support.design.widget.AppBarLayout>
  <FrameLayout
      android:id="@+id/fl_container_base_amcat"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
  <!--Question View Anchor Fab-->    
  <android.support.design.widget.FloatingActionButton
      android:id="@+id/fab1_language"
      android:layout_width="wrap_content"
      android:layout_height="@dimen/fab_size_40"
      android:layout_marginEnd="@dimen/activity_horizontal_margin"
      android:layout_marginRight="@dimen/activity_horizontal_margin"
      android:layout_marginTop="@dimen/margin_fab_first"
      android:clickable="true"
      android:scaleType="center"
      android:src="@drawable/ic_fab_language"
      app:backgroundTint="@color/bg_color_fab_language"
      app:layout_anchor="@+id/toolbar_base_question_activity"
      app:layout_anchorGravity="bottom|right|end"/>
  <!--info view anchor FAB-->
  <android.support.design.widget.FloatingActionButton
      android:id="@+id/fab2_info"
      android:layout_width="wrap_content"
      android:layout_height="@dimen/fab_size_40"
      android:layout_marginEnd="@dimen/activity_horizontal_margin"
      android:layout_marginRight="@dimen/activity_horizontal_margin"
      android:layout_marginTop="@dimen/margin_fab_second"
      android:clickable="true"
      android:scaleType="center"
      android:src="@drawable/ic_fab_info"
      android:visibility="gone"
      app:backgroundTint="@color/bg_color_fab_info"
      app:layout_anchor="@+id/fab1_language"
      app:layout_anchorGravity="bottom|center_horizontal"/>
  <android.support.design.widget.FloatingActionButton
      android:id="@+id/fab3_question"
      android:layout_width="wrap_content"
      android:layout_height="@dimen/fab_size_40"
      android:layout_marginEnd="@dimen/activity_horizontal_margin"
      android:layout_marginRight="@dimen/activity_horizontal_margin"
      android:layout_marginTop="@dimen/margin_fab_third"
      android:clickable="true"
      android:scaleType="center"
      android:src="@drawable/ic_fab_question"
      android:visibility="gone"
      app:backgroundTint="@color/bg_color_fab_question"
      app:layout_anchor="@+id/fab2_info"
      app:layout_anchorGravity="bottom|center_horizontal"/>
  <RelativeLayout android:id="@+id/simple_overlay_container"
                  xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:tools="http://schemas.android.com/tools"
                  app:layout_anchor="@+id/main.appbar"
                  app:layout_anchorGravity="top|left"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:background="@color/transparent_overlay_gray_75"
                  android:visibility="gone"
                  android:clickable="true">

    <ImageButton
        android:id="@+id/imageButton_zoom_image_answer_tutorial"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="@android:color/transparent"
        android:paddingEnd="@dimen/margin_12"
        android:paddingRight="@dimen/margin_12"
        android:paddingTop="@dimen/margin_12"
        android:src="@drawable/ic_zoom"
        android:visibility="gone"
        tools:ignore="RtlSymmetry"/>

  </RelativeLayout>
</android.support.design.widget.CoordinatorLayout>

我需要帮助将此视图置于工具栏上方以覆盖整个屏幕,其中包括活动和工具栏,而不是状态栏或导航栏。

我感谢您的帮助。提前致谢。


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

创建一个覆盖视图以覆盖整个活动,包括协调器布局中的工具栏 的相关文章

  • Spring RESTful控制器方法改进建议

    我是 Spring REST 和 Hibernate 的新手 也就是说 我尝试组合一个企业级控制器方法 我计划将其用作未来开发的模式 您认为可以通过哪些方法来改进 我确信有很多 RequestMapping value user metho
  • 从脚本内更改自动热键托盘图标

    如何从 Autohotkey 脚本中将托盘图标更改为 my ico 例如 当脚本暂停时 为此 我在托盘菜单中提出了自己的 暂停脚本 菜单项 SingleInstance ignore Menu Tray Tip AutoCase 0 11
  • 文本溢出:省略号显示不同的字符

    我这里遇到了一些 CSS 问题 看这张图片 https www flickr com photos 125543025 N07 saved 1 在此图像中 我为文本 INTENSE TRAINING 添加了 CSS 样式 sample st
  • 我们什么时候应该在 Django 中使用“db_index=True”?

    当我们应该定义db index True在模型字段上 我正在尝试优化应用程序并且我想了解更多信息db index 什么情况下我们应该使用它 文档说使用db index True在模型字段上用于加速查找 但在存储和内存方面略有缺点 我们应该使
  • 使用 QtWebEngine 将 C++ 对象暴露给 Qt 中的 Javascript

    使用 QtWebkit 可以通过以下方式将 C 对象公开给 JavascriptQWebFrame addToJavaScriptWindowObject如中所述https stackoverflow com a 20685002 5959
  • Android Espresso 单击按钮时出现错误

    我正在尝试使用 espresso 框架为 Android 应用程序编写一些 UI 测试 现在我只是检查启动屏幕上是否存在所有元素 然后尝试单击登录按钮 单击按钮时 测试由于错误而失败 我似乎无法理解为什么会发生这种情况 我的测试代码是 Ru
  • Qt 布局,在小部件大小更改后调整到最小大小

    基本上我有一个QGridLayout里面有一些小部件 最重要的是 2 个标签 我用它们将图像绘制到屏幕上 好吧 如果用户愿意 他可以更改传入图像的分辨率 从而强制标签调整大小 我们假设标签的初始大小是320x240 用户将 VideoMod
  • Python 中的字符串slugification

    我正在寻找 slugify 字符串的最佳方法 蛞蝓 是什么 https stackoverflow com questions 427102 in django what is a slug 我当前的解决方案基于这个食谱 http code
  • bash:gitolite:找不到命令

    我正在尝试使用 Gitolite 在 Gitlab 中创建一个新分支 我完成安装步骤 当我遇到 设置 gitolite 部分时 我遇到了麻烦 我跟着这个link http sitaramc github com gitolite setup
  • 如何在 kubernetes 中将秘密标记为可选?

    来自文档 除非将秘密标记为可选 否则必须先创建秘密 然后再将其作为环境变量在 pod 中使用 引用不存在的 Secret 将阻止 pod 启动 如何将秘密标记为可选 您正在寻找的是 name ENV NAME valueFrom secre
  • ASP.NET Core MVC 视图组件搜索路径

    在此处的文档中 https learn microsoft com en us aspnet core mvc views view components view aspnetcore 2 2 https learn microsoft
  • xsi:type 属性搞乱了 C# XML 反序列化

    我使用 XSD exe 根据 XML 架构 xsd 文件 自动生成 C 对象 我正在反序列化 OpenCover 输出 但其中一个部分类未正确生成 这是导致异常的行
  • 一些基本的 PHP 问题 [已关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我只是有一些基本的 php 问题来加深我对学习的理解 但我找不到简单的答案 我有一个 php ajax 应用程序 它生成 mysql
  • If else 在 Web 网格列中

    如何在 webgrid 列中添加条件 if else grid GetHtml tableStyle table table bordered columns grid Columns grid Column RealName Name g
  • View.post(),以及当Runnables被执行时

    我最初的问题是需要知道我的根的高度和宽度View这样我就可以进行程序化的布局更改 就我的目的而言 我不一定需要在onCreate 对于我来说 以编程方式添加我的孩子就足够了View根布局完成后 因此我很乐意使用onWindowFocusCh
  • Azure Functions 计时器触发器线程安全

    我想知道是否有人知道如果您在 Azure 函数上设置了 Cron 设置 如果其任务执行时间超过 5 分钟 则每 5 分钟运行一次 会发生什么情况 它备份吗 或者我应该实现一个锁定功能 以防止某些东西 例如在循环中 处理先前调用已经处理的数据
  • React 错误:目标容器不是 DOM 元素

    我刚刚开始使用 React 所以这可能是一个非常简单的错误 但我们开始吧 我的html代码非常简单 load staticfiles
  • 自定义字符串查询操作的 Linq to NHibernate 可扩展性?

    我希望能够在 NHibernate Linq 表达式中使用自定义字符串查询 举例来说 这只是一个例子 我希望能够选择包含属性的实体 该属性是特定字符串的字谜 var myEntities EntityRepository AllEntiti
  • Keystore getEntry 在 Android 9 上返回 NULL

    c我已对存储在 Android 密钥库中的登录密码进行了加密和解密 在 Android 9 上 我观察到应用程序在尝试解密密码时崩溃 我无法重现它 但拥有 Pixel 3 的用户是崩溃的设备之一 下面是我如何从密钥库解密密码 private
  • 如何使用 dql 从数据表中获取唯一值?

    我有一个表 其中有一列存储了各种值 我想使用 dql 从该表中检索唯一值 Doctrine Query create gt select rec school gt from Records rec gt where rec city ci

随机推荐