获取底部虚拟按键高度
2023-01-24 09:16:15 最后更新
import "android.util.*"
import "java.lang.*"
  import "android.util.DisplayMetrics"
function getScreenPhysicalSize(ctx) 
  dm = DisplayMetrics();
  ctx:getWindowManager():getDefaultDisplay():getMetrics(dm);
  diagonalPixels = Math:sqrt(Math:pow(dm.widthPixels, 2) + Math:pow(dm.heightPixels, 2));
  return diagonalPixels / (160 * dm.density);
end
function getBottomKeyboardHeight()
           screenHeight = getScreenPhysicalSize(activity)

           dm = DisplayMetrics()
        activity:getWindowManager():getDefaultDisplay():getMetrics(dm)
           heightDifference = screenHeight - dm.heightPixels 
           return heightDifference
end
syso(getBottomKeyboardHeight())
iApp一本通