package com.atmob.keyboard_android.util

import android.view.View

/**
 * View的位置工具类
 */
class ViewLocationUtil private constructor() {
    companion object {
        /**
         * 获取View在Window中的坐标
         */
        fun getViewLocationInWindow(view: View): IntArray {
            val location = IntArray(2)
            view.getLocationInWindow(location)
            // View 左上角的 X 坐标
            val x = location[0]
            // View 左上角的 Y 坐标
            val y = location[1]
            return intArrayOf(x, y)
        }
    }
}