No Description

SystemUtils.java 1.4KB

    package ai.pai.lensman.utils; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.os.Build; import android.view.View; import android.view.Window; import android.view.WindowManager; /** * Created by chengzhenyu on 2016/2/29. */ public class SystemUtils { @SuppressLint("InlinedApi") public static void setImmerseLayout(Activity context, View view) { if (context == null || view == null) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window window = context.getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); int statusBarHeight = getStatusBarHeight(context.getBaseContext()); view.setPadding(0, statusBarHeight, 0, 0); } } /** * 用于获取状态栏的高度。 使用Resource对象获取(推荐这种方式) * * @return 返回状态栏高度的像素值。 */ public static int getStatusBarHeight(Context context) { int result = 0; int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = context.getResources().getDimensionPixelSize(resourceId); } return result; } }
Inloggen - Gogs: Go Git Service

Inloggen