android - 代号一:隐藏标题(区域)但不隐藏状态栏空间(iOS & Android)
问题描述
我有一个适用于 iOS 和 Android 的应用程序。状态栏没有隐藏。我的主窗体没有标题,没有后退命令,工具栏中也没有其他命令。(我所有的其他表单都有一个标题和返回命令。)我想隐藏标题,因为我需要空间。我发现在 iOS 设备上,一个空标题 ("") 可以完成这项工作。但在 Android 设备上却没有;第一次调用 form.show() 时不显示表单内容。如果我们暂停和恢复应用程序,它就会显示出来。Android 实现似乎需要一个非空标题,即使它是隐藏的。
所以我的实现是:
// we use Toolbar.setGlobalToolbar(true)
public class MainForm extends Form {
public MainForm() {
super(""); // hides the title area but not the status bar space on iOS
if (android()) {
setTitle(" "); // Android needs non-empty title
getToolbar().hideToolbar(); // hides the title area; don't use on iOS, it removes the status bar space too
}
...
这是一个正确的实现吗?我找不到任何关于此的文档。
在以下评论后编辑:
我也在 ios 上尝试了 getToolbar().setUIID("Container") 的建议。这将删除工具栏顶部填充,因此只剩下状态栏。但是,至少在模拟器中,状态栏的底部不再与 iPhone X 凹槽的底部对齐(它在其上方)。所以我认为填充是必要的,就像在具有标题(和返回命令)的表单上一样。所以我得出以下实现:
// hide title area
super(""); // hides title area on ios (not status bar space and toolbar padding)
if (android()) {
// hide title area (=toolbar) explicitly
// use *either* this:
getToolbar().hideToolbar(); // on ios this also hides the status bar space
// *or* this:
getToolbar().setUIID("Container"); // on ios this also hides the Toolbar top padding
}
这个对吗?
解决方案
推荐阅读
- python - 为什么我无法在熊猫中获得正确的掩码列
- data-structures - 将平衡二叉树复制到具有最小旋转的 AVL 树的最佳“顺序”遍历
- robot - 通用机器人 TCP/IP 通信:无法发送 crlf ("\r\n")
- python - 尝试在指定路径中制作自复制文件
- sql - User 和 UserInfo 之间的映射
- angular - Angular 9 库:从主入口点到辅助入口点的依赖关系
- python - 通过子进程 python 调用时,tesseract 不显示任何输出
- unit-testing - 在包装函数中对正确的库使用进行通用测试是不好的做法吗?
- linux - 更改 cgroup pid.max 值?
- xunit - 使用内存中的 EF Core 提供程序时,在单元测试期间无法获取 EF Core 日志