thieumao

getActionBarHeight, getStatusBarHeight in Android

May 4th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.59 KB | None | 0 0
  1.     private fun getActionBarHeight(): Int {
  2.         val styledAttributes = activity.getTheme().obtainStyledAttributes(intArrayOf(android.R.attr.actionBarSize))
  3.         val actionBarSize = styledAttributes.getDimension(0, 0f).toInt()
  4.         styledAttributes.recycle()
  5.         return actionBarSize
  6.     }
  7.  
  8.     private fun getStatusBarHeight(): Int {
  9.         var result = 0
  10.         val resourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
  11.         if (resourceId > 0) {
  12.             result = resources.getDimensionPixelSize(resourceId)
  13.         }
  14.         return result
  15.     }
Advertisement
Add Comment
Please, Sign In to add comment