java - 如何使 ActionBar 在活动中不可见?
问题描述
我想让我的活动的 actionBar 不可见。hide()
对我不起作用,因为它完全删除了 actionBar 并且活动在隐藏后不会保持视图的高度。
我怎样才能做到这一点?
编辑(代码更新):
布局.xml:
<LinearLayout
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal">
<ImageButton
android:id="@+id/detail_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_back_dark"
android:contentDescription="@string/back_button"
android:background="?attr/selectableItemBackgroundBorderless"
android:padding="16dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/user_selected_name_surname"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Detail"
android:textSize="22sp"
android:gravity="center|start"/>
</LinearLayout>
<View
android:id="@+id/top_bar_divider"
android:layout_below="@id/notification_top_bar"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/grey_color"/>
在activity.java中,我简单地将线性布局和分隔线设置为INVISIBLE:
topBar.setVisibility(View.INVISIBLE);
topBarDivider.setVisibility(View.INVISIBLE);
解决方案
推荐阅读
- blender - Blender 命令行导入文件
- elixir - 无法创建 Rumbl.Repo 的数据库:已杀死
- javascript - 到达页面顶部时如何将tr粘贴在表格中间
- c# - 无法解析类型:System.String、System.Private.CoreLib、版本 4.0.0.0 - Asp.net Core (.net core 2.1) 服务器、.NET 4.6.1 客户端
- android - 当我单击警报对话框中的 Recycler 视图项时,它显示错误:活动已泄漏窗口 DecorView@1ac0c00[] 最初添加在此处
- python - python 3.6之前有没有像__init_subclass__()这样的方法
- json - 带有 json 编码的 avro 模式 - 如何从序列化数据中确定模式
- c# - 如何在使用迁移更新数据库期间修复关键字“NOT”附近的错误语法
- c++ - 如何使用 qmake 将 pcl 库成功添加到 qt 项目中
- vba - VBA 创建具有不同行长度的 CSV