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
The Class Summary is usually a good place to start. I think the getHeight() method should suffice.
EDIT:
If you need the width, it should be the width of the screen (right?) and that can be gathered like this.
@AZ13's answer is good, but as per the Android design guidelines, the ActionBar should be at least 48dp high.
If you're using the compatibility ActionBar from the recent v7 appcompat support package, you can get the height using
Documentation
From the de-compiled sources of Android 3.2's
framework-res.apk
,res/values/styles.xml
contains:3.0 and 3.1 seem to be the same (at least from AOSP)...
I needed to do replicate these heights properly in a pre-ICS compatibility app and dug into the framework core source. Both answers above are sort of correct.
It basically boils down to using qualifiers. The height is defined by the dimension "action_bar_default_height"
It is defined to 48dip for default. But for -land it is 40dip and for sw600dp it is 56dip.
I did in this way for myself, this helper method should come in handy for someone: