package com.sjl.yuehu.util; import android.content.Context; import android.content.res.Resources; import android.os.Build; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import java.lang.reflect.Method; /** * Created by hefuyi on 16/7/30. */ public class UIUtils { public static void setAccessiblityIgnore(View view) { view.setClickable(false); view.setFocusable(false); view.setContentDescription(""); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); } } public static int getStatusBarHeight(Context context) { Resources resources = context.getResources(); int resourcesId = resources.getIdentifier("status_bar_height", "dimen", "android"); int height = resources.getDimensionPixelSize(resourcesId); return height; } public static final View inflate(int resId, ViewGroup parent) { return LayoutInflater.from(parent.getContext()).inflate(resId, parent, false); } public static int getNavigationBarHeight(Context context) { Resources resources = context.getResources(); int resourcesId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); int height = resources.getDimensionPixelSize(resourcesId); return height; } public static boolean hasNavigationBar(Context activity) { boolean hasNavigationBar = false; Resources resources = activity.getResources(); int id = resources.getIdentifier("config_showNavigationBar", "bool", "android"); if (id > 0) { hasNavigationBar = resources.getBoolean(id); } try { Class systemPropertiesClass = Class.forName("android.os.SystemProperties"); Method method = systemPropertiesClass.getMethod("get", String.class); String navBarOverride = (String) method.invoke(systemPropertiesClass, "qemu.hw.mainkeys"); if ("1".equals(navBarOverride)) { hasNavigationBar = false; } else if ("0".equals(navBarOverride)) { hasNavigationBar = true; } } catch (Exception e) { // L.e("UIUtiles", e.toString()); } return hasNavigationBar; } }