package cn.flightfeather.thirdapp.common; import android.os.Build; import android.support.v4.app.Fragment; import android.view.ViewGroup; /** * Created by note_ff_1603 on 2017/7/28. */ public class StatusBar { private Fragment fragment; public StatusBar(Fragment fragment) { this.fragment = fragment; } public StatusBar(android.app.Fragment fragment) { } public StatusBar(){ } //初始化半透明状态栏 public void initTransparentStatsBar(ViewGroup viewGroup) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { viewGroup.setPadding(0, getStatusBarHeight(), 0, 0); } } //获得状态栏高度 public int getStatusBarHeight() { int result = 0; int resourceId = fragment.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = fragment.getResources().getDimensionPixelSize(resourceId); } return result; } }