【Android view】获取状态栏高度statu bar height的正确姿势

                                                                Android设备获取状态栏高度的正确姿势

int height = 0;  
int resourceId = getApplicationContext().getResources().getIdentifier("status_bar_height", "dimen", "android");  
if (resourceId > 0) {  
    height = getApplicationContext().getResources().getDimensionPixelSize(resourceId);  
}  
使用:在onCreate()方法中调用,与setonContentView()前后顺序无关。


你可能感兴趣的:(android,View系列)