I need to know the exact size of ActionBar in pixels so to apply correct background image.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
With the new v7 support library (21.0.0) the name in
R.dimen
has changed to @dimen/abc_action_bar_default_height_material.When upgrading from a previous version of the support lib you should therefore use that value as the actionbar's height
To retrieve the height of the ActionBar in XML, just use
or if you're an ActionBarSherlock or AppCompat user, use this
If you need this value at runtime, use this
If you need to understand where this is defined:
To get the actual height of the Actionbar, you have to resolve the attribute
actionBarSize
at runtime.One of the Honeycomb samples refers to
?android:attr/actionBarSize
On my Galaxy S4 having > 441dpi > 1080 x 1920 > Getting Actionbar height with getResources().getDimensionPixelSize I got 144 pixels.
Using formula px = dp x (dpi/160), I was using 441dpi, whereas my device lies
in the category 480dpi. so putting that confirms the result.
If you are using ActionBarSherlock, you can get the height with