Androidは下部のナビゲーションバーの高さを取得します



Android Gets Bottom Navigation Bar Height



デバイスの下部のナビゲーションバーの高さを取得します

/** * Get the bottom navigation bar height */ private fun getNavigationBarHeight(): Int { if (!isNavigationBarShow()) { return 0 } val resourceId = resources.getIdentifier('navigation_bar_height', 'dimen', 'android') / / Get the height of the NavigationBar return resources.getDimensionPixelSize(resourceId) }

下部のナビゲーションバーが表示されているかどうかを確認します

/** * Whether the bottom navigation is displayed */ private fun isNavigationBarShow(): Boolean { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { val display = windowManager.defaultDisplay val size = Point() val realSize = Point() display.getSize(size) display.getRealSize(realSize) return realSize.y !== size.y } else back) false else true }

隠しキーボード入力方式

private fun hintKeyBoard() { / / Get the InputMethodManager val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager / / If the view on the window gets the focus && view is not empty if (imm.isActive && currentFocus != null) { / / Get the view token is not empty if (currentFocus!!.windowToken != null) { // indicates that the soft keyboard window is always hidden unless it is initially displayed with SHOW_FORCED. imm.hideSoftInputFromWindow(currentFocus!!.windowToken, InputMethodManager.HIDE_NOT_ALWAYS) } } }

ヒント:この方法は基本的に全画面では無効です