这是indexloc提供的服务,不要输入任何密码
Skip to content

怎样获得屏幕底部高度? #456

@wengzhenquan

Description

@wengzhenquan

场景:
因为微信小程序在不同设备可能存在布局分析失效,导致只能用坐标点击(当布局分析失效时)。
需要点击的是底部的导航键,比如点击“论坛”、“我的”,大概位置就是在微信底部“通讯录”、“发现”、“我”。

当然,如果高度使用0.98*device.height,理论上是没问题的。
但是,如果出现虚拟按键,就不适用了。

此前,通过ui.statusBarHeight可以获得状态栏高度。所以我想问问能否得到软件底部的位置(或虚拟按键上方边界)?

如果是全面屏手势模式,底部的位置肯定是device.height,那么稍微上移那么一点点,就可以得到需要点击的高度。

如果是底部虚拟按键模式,我也需要得到按键上方那条横线的位置,然后上移一点点也可以得到需要点击的高度。

那么怎么得到这条横线的位置呢?
不论是从上往下寻找,还是从下往上寻找,都可以。

Metadata

Metadata

Assignees

No one assigned

    Labels

    Accepted 🌱 受理Maintainer may be busy resolving or fixing the labeled issuesDelayed ⌛ 延期Issues have been accepted but won't be settled in timeFeedback Awaited 🕒 等待反馈Waiting for the feedback from issue creater and issue will be closed if duration is over one monthProposal 💡 方案Issue creater's own proposal which may be really helpfulReinforcement ✨ 强化Issues for higher quality of being compatible

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions