【问题标题】:Android:How to get the coordinate of a view(not include Actionbar)Android:如何获取视图的坐标(不包括Actionbar)
【发布时间】:2016-03-08 01:18:52
【问题描述】:

使用View.getLocationOnScreen()可以得到坐标,但是比我想象的要大一点,所以我认为我得到的坐标是相对于全屏的(包括ActionBar)。 有没有什么方法可以在不包含ActionBar的情况下获得坐标? 见下图。

【问题讨论】:

标签: android view


【解决方案1】:

请先看这张图片:

此链接向您展示如何获取按钮的当前位置(图片中的 110)

How to get the absolute coordinates of a view

第二个链接计算Actionbar高度(图中72)

How to get the ActionBar height?

最后一个链接告诉你如何计算状态栏(图中38)

Height of status bar in Android

现在你可以用这个 equal(110 = 72 + 38) 得到当前位置

希望能帮到你。

【讨论】:

    猜你喜欢
    • 2013-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-14
    • 1970-01-01
    • 2019-07-23
    • 2014-08-27
    • 1970-01-01
    相关资源
    最近更新 更多