{"id":205,"date":"2018-12-20T13:27:47","date_gmt":"2018-12-20T05:27:47","guid":{"rendered":"https:\/\/qtvz.com\/?p=205"},"modified":"2018-12-20T13:27:47","modified_gmt":"2018-12-20T05:27:47","slug":"android-%e6%b2%89%e6%b5%b8%e5%bc%8f%e7%8a%b6%e6%80%81%e6%a0%8f%e5%ae%8c%e7%be%8e%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88","status":"publish","type":"post","link":"https:\/\/qtvz.com\/205.html","title":{"rendered":"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"<!--wp-compress-html--><!--wp-compress-html no compression--><p>\u6ce8\u660e\u4e0b,\u8fd9\u91cc\u53ea\u8bb2\u72b6\u6001\u680f,\u5bfc\u822a\u680f\u540e\u9762\u770b\u6709\u6ca1\u6709\u5fc5\u8981\u518d\u8bb2<br \/>\n\u56fd\u5185\u5f88\u591a\u7c7b\u4f3c\u7684\u6587\u7ae0, \u6211\u53ea\u60f3\u8bf4\u4e00\u4e2a\u5b57, \u771ftm\u4e71! \u6211\u770b\u4e0d\u61c2\u2026 \u8bc4\u8bba\u91cc\u9762 \u5168\u5728\u8bf4\u65e0\u6548\u4ec0\u4e48\u7684 (\u6211\u8bd5\u4e86\u4e5f\u65e0\u6548, \u597d\u5389\u5bb3\u7684\u6837\u5b50)<\/p>\n<p>\u4e0d\u5e9f\u8bdd,\u56de\u5230\u6b63\u9898, \u9996\u5148\u8d34\u4e0a\u4e00\u4e2a\u4f17\u6240\u5468\u77e5\u7684\u5e93 SystemBarTint<br \/>\n\u6211\u53ea\u8981\u8fd9\u4e2a\u7c7b<br \/>\nhttps:\/\/github.com\/jgilfelt\/SystemBarTint\/blob\/master\/library\/src\/com\/readystatesoftware\/systembartint\/SystemBarTintManager.java (\u672c\u6587\u540e\u6709\u8be5\u6587\u4ef6)<br \/>\n\u7136\u540e\u590d\u5236\u5230\u4f60\u7684\u5de5\u7a0b<br \/>\n\u8fd9\u4e2a\u7c7b\u6211\u5c31\u4e0d\u591a\u8bf4\u4e86, \u5c31\u662f\u517c\u5bb94.x\u4ee5\u4e0a\u6c89\u6d78\u900f\u660e\u72b6\u6001\u680f\u7684 \u4e00\u4e2a\u517c\u5bb9\u7c7b, \u6709\u7a7a\u53ef\u4ee5\u7814\u7a76\u4e0b<\/p>\n<p>\u5148\u8d34\u5de5\u5177\u7c7b, \u6709\u90e8\u5206\u4ee3\u7801\u53c2\u8003\u81ea\u7f51\u4e0a\u5e76\u6709\u505a\u6539\u52a8, \u4f46\u8fd9,\u4e0d\u91cd\u8981\u2026<\/p>\n<pre class=\"lang:default decode:true \" title=\"StatusBarUtil\">public class StatusBarUtil {\r\n    public final static int TYPE_MIUI = 0;\r\n    public final static int TYPE_FLYME = 1;\r\n    public final static int TYPE_M = 3;\/\/6.0\r\n\r\n    @IntDef({TYPE_MIUI,\r\n            TYPE_FLYME,\r\n            TYPE_M})\r\n    @Retention(RetentionPolicy.SOURCE)\r\n    @interface ViewType {\r\n    }\r\n\r\n    \/**\r\n     * \u4fee\u6539\u72b6\u6001\u680f\u989c\u8272\uff0c\u652f\u63014.4\u4ee5\u4e0a\u7248\u672c\r\n     *\r\n     * @param colorId \u989c\u8272\r\n     *\/\r\n    public static void setStatusBarColor(Activity activity, int colorId) {\r\n\r\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {\r\n            Window window = activity.getWindow();\r\n            window.setStatusBarColor(colorId);\r\n        } else if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {\r\n            \/\/\u4f7f\u7528SystemBarTintManager,\u9700\u8981\u5148\u5c06\u72b6\u6001\u680f\u8bbe\u7f6e\u4e3a\u900f\u660e\r\n            setTranslucentStatus(activity);\r\n            SystemBarTintManager systemBarTintManager = new SystemBarTintManager(activity);\r\n            systemBarTintManager.setStatusBarTintEnabled(true);\/\/\u663e\u793a\u72b6\u6001\u680f\r\n            systemBarTintManager.setStatusBarTintColor(colorId);\/\/\u8bbe\u7f6e\u72b6\u6001\u680f\u989c\u8272\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * \u8bbe\u7f6e\u72b6\u6001\u680f\u900f\u660e\r\n     *\/\r\n    @TargetApi(19)\r\n    public static void setTranslucentStatus(Activity activity) {\r\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {\r\n            \/\/5.x\u5f00\u59cb\u9700\u8981\u628a\u989c\u8272\u8bbe\u7f6e\u900f\u660e\uff0c\u5426\u5219\u5bfc\u822a\u680f\u4f1a\u5448\u73b0\u7cfb\u7edf\u9ed8\u8ba4\u7684\u6d45\u7070\u8272\r\n            Window window = activity.getWindow();\r\n            View decorView = window.getDecorView();\r\n            \/\/\u4e24\u4e2a flag \u8981\u7ed3\u5408\u4f7f\u7528\uff0c\u8868\u793a\u8ba9\u5e94\u7528\u7684\u4e3b\u4f53\u5185\u5bb9\u5360\u7528\u7cfb\u7edf\u72b6\u6001\u680f\u7684\u7a7a\u95f4\r\n            int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN\r\n                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;\r\n            decorView.setSystemUiVisibility(option);\r\n            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);\r\n            window.setStatusBarColor(Color.TRANSPARENT);\r\n            \/\/\u5bfc\u822a\u680f\u989c\u8272\u4e5f\u53ef\u4ee5\u6b63\u5e38\u8bbe\u7f6e\r\n            \/\/window.setNavigationBarColor(Color.TRANSPARENT);\r\n        } else if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {\r\n            Window window = activity.getWindow();\r\n            WindowManager.LayoutParams attributes = window.getAttributes();\r\n            int flagTranslucentStatus = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;\r\n            attributes.flags |= flagTranslucentStatus;\r\n            \/\/int flagTranslucentNavigation = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;\r\n            \/\/attributes.flags |= flagTranslucentNavigation;\r\n            window.setAttributes(attributes);\r\n        }\r\n    }\r\n\r\n\r\n    \/**\r\n     *  \u4ee3\u7801\u5b9e\u73b0android:fitsSystemWindows\r\n     *\r\n     * @param activity\r\n     *\/\r\n    public static void setRootViewFitsSystemWindows(Activity activity, boolean fitSystemWindows) {\r\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {\r\n            ViewGroup winContent = (ViewGroup) activity.findViewById(android.R.id.content);\r\n            if (winContent.getChildCount() &gt; 0) {\r\n                ViewGroup rootView = (ViewGroup) winContent.getChildAt(0);\r\n                if (rootView != null) {\r\n                    rootView.setFitsSystemWindows(fitSystemWindows);\r\n                }\r\n            }\r\n        }\r\n\r\n    }\r\n\r\n\r\n    \/**\r\n     * \u8bbe\u7f6e\u72b6\u6001\u680f\u6df1\u8272\u6d45\u8272\u5207\u6362 \r\n     *\/\r\n    public static boolean setStatusBarDarkTheme(Activity activity, boolean dark) {\r\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {\r\n            if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {\r\n                setStatusBarFontIconDark(activity, TYPE_M, dark);\r\n            } else if (OSUtils.isMiui()) {\r\n                setStatusBarFontIconDark(activity, TYPE_MIUI, dark);\r\n            } else if (OSUtils.isFlyme()) {\r\n                setStatusBarFontIconDark(activity, TYPE_FLYME, dark);\r\n            } else {\/\/\u5176\u4ed6\u60c5\u51b5\r\n                return false;\r\n            }\r\n\r\n            return true;\r\n        }\r\n        return false;\r\n    }\r\n\r\n    \/**\r\n     * \u8bbe\u7f6e \u72b6\u6001\u680f\u6df1\u8272\u6d45\u8272\u5207\u6362\r\n     *\/\r\n    public static boolean setStatusBarFontIconDark(Activity activity, @ViewType int type,boolean dark) {\r\n        switch (type) {\r\n            case TYPE_MIUI:\r\n                return setMiuiUI(activity, dark);\r\n            case TYPE_FLYME:\r\n                return setFlymeUI(activity, dark);\r\n            case TYPE_M:\r\n            default:\r\n                return setCommonUI(activity,dark);\r\n        }\r\n    }\r\n\r\n    \/\/\u8bbe\u7f6e6.0 \u72b6\u6001\u680f\u6df1\u8272\u6d45\u8272\u5207\u6362\r\n    public static boolean setCommonUI(Activity activity, boolean dark) {\r\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {\r\n            View decorView = activity.getWindow().getDecorView();\r\n            if (decorView != null) {\r\n                int vis = decorView.getSystemUiVisibility();\r\n                if (dark) {\r\n                    vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;\r\n                } else {\r\n                    vis &amp;= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;\r\n                }\r\n                if (decorView.getSystemUiVisibility() != vis) {\r\n                    decorView.setSystemUiVisibility(vis);\r\n                }\r\n                return true;\r\n            }\r\n        }\r\n        return false;\r\n\r\n    }\r\n\r\n    \/\/\u8bbe\u7f6eFlyme \u72b6\u6001\u680f\u6df1\u8272\u6d45\u8272\u5207\u6362\r\n    public static boolean setFlymeUI(Activity activity, boolean dark) {\r\n        try {\r\n            Window window = activity.getWindow();\r\n            WindowManager.LayoutParams lp = window.getAttributes();\r\n            Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField(\"MEIZU_FLAG_DARK_STATUS_BAR_ICON\");\r\n            Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField(\"meizuFlags\");\r\n            darkFlag.setAccessible(true);\r\n            meizuFlags.setAccessible(true);\r\n            int bit = darkFlag.getInt(null);\r\n            int value = meizuFlags.getInt(lp);\r\n            if (dark) {\r\n                value |= bit;\r\n            } else {\r\n                value &amp;= ~bit;\r\n            }\r\n            meizuFlags.setInt(lp, value);\r\n            window.setAttributes(lp);\r\n            return true;\r\n        } catch (Exception e) {\r\n            e.printStackTrace();\r\n            return false;\r\n        }\r\n    }\r\n\r\n    \/\/\u8bbe\u7f6eMIUI \u72b6\u6001\u680f\u6df1\u8272\u6d45\u8272\u5207\u6362\r\n    public static boolean setMiuiUI(Activity activity, boolean dark) {\r\n        try {\r\n            Window window = activity.getWindow();\r\n            Class&lt;?&gt; clazz = activity.getWindow().getClass();\r\n            @SuppressLint(\"PrivateApi\") Class&lt;?&gt; layoutParams = Class.forName(\"android.view.MiuiWindowManager$LayoutParams\");\r\n            Field field = layoutParams.getField(\"EXTRA_FLAG_STATUS_BAR_DARK_MODE\");\r\n            int darkModeFlag = field.getInt(layoutParams);\r\n            Method extraFlagField = clazz.getDeclaredMethod(\"setExtraFlags\", int.class, int.class);\r\n            extraFlagField.setAccessible(true);\r\n            if (dark) {    \/\/\u72b6\u6001\u680f\u4eae\u8272\u4e14\u9ed1\u8272\u5b57\u4f53\r\n                extraFlagField.invoke(window, darkModeFlag, darkModeFlag);\r\n            } else {\r\n                extraFlagField.invoke(window, 0, darkModeFlag);\r\n            }\r\n            return true;\r\n        } catch (Exception e) {\r\n            e.printStackTrace();\r\n            return false;\r\n        }\r\n    }\r\n    \/\/\u83b7\u53d6\u72b6\u6001\u680f\u9ad8\u5ea6\r\n    public static int getStatusBarHeight(Context context) {\r\n        int result = 0;\r\n        int resourceId = context.getResources().getIdentifier(\r\n                \"status_bar_height\", \"dimen\", \"android\");\r\n        if (resourceId &gt; 0) {\r\n            result = context.getResources().getDimensionPixelSize(resourceId);\r\n        }\r\n        return result;\r\n    }\r\n}<\/pre>\n<p>\u597d\u4e86,\u8fd9\u4e2a\u7c7b \u652f\u6301\u4e86 \u8bbe\u7f6e\u72b6\u6001\u680f\u900f\u660e, \u8bbe\u7f6e\u72b6\u6001\u680f\u989c\u8272, \u652f\u6301\u4e86\u72b6\u6001\u680f\u6df1\u8272\u6d45\u8272\u5207\u6362(\u5219\u72b6\u6001\u680f\u4e0a\u7684\u6587\u5b57\u56fe\u6807\u989c\u8272)<\/p>\n<p>\u5982\u679c\u4f60\u5728\u770b\u8fd9\u7bc7\u6587\u7ae0, \u5148\u4e0d\u8981\u770b\u522b\u7684\u6587\u7ae0 (23333..) .\u56e0\u4e3a\u53ef\u80fd\u4f1a\u6270\u4e71\u4f60\u7684\u601d\u8def,,\u5bfc\u81f4\u4f60\u65e0\u6cd5\u7406\u89e3\u548c\u4f7f\u7528, \u5e76\u4e14\u4f60\u4e71\u5165\u7684\u4ee3\u7801\u4f1a\u5e72\u6270\u8fd9\u8fb9\u7684\u4ee3\u7801\u6b63\u5e38\u5de5\u4f5c, \u5148\u5220\u6389\u4f60\u5728\u522b\u7684\u6587\u7ae0\u7684\u4ee3\u7801\u4fee\u6539, \u76f8\u4fe1\u6211, \u6211\u8fd9\u8fb9\u5565\u90fd\u4e0d\u7528\u505a, \u4f60\u7edd\u5bf9\u80fd\u4ee5\u6700\u7b80\u5355\u7684\u65b9\u5f0f \u8ba9\u4f60\u7684\u9879\u76ee\u5b9e\u73b0\u6c89\u6d78\u72b6\u6001\u680f\u517c\u5bb9~ \u5305\u62ec\u56fe\u7247\u6c89\u6d78!<\/p>\n<p>\u524d\u671f\u51c6\u5907:<br \/>\n\u6211\u5c31\u6015\u4f60\u641e\u4e86\u4e00\u5806\u5728\u522b\u7684\u6587\u7ae0\u7684\u914d\u7f6e,\u6240\u4ee5\u6211\u8fd8\u662f\u8981\u8bf4\u4e0b\u4ee5\u4e0b\u4ee3\u7801\u4e0d\u80fd\u51fa\u73b0:<br \/>\n\u5168\u5c40\u641c\u7d22\u4f60\u7684\u4ee3\u7801\u91cc \u662f\u5426\u6709 android:fitsSystemWindows , \u5220\u6389!, \u6ca1\u9519 \u5220\u6389!!!<br \/>\n\u68c0\u67e5\u4f60\u7684values\u3001values-v19\u3001values-v21\u7b49 \u662f\u5426\u914d\u7f6e\u4e86<br \/>\n\u5982\u4e0bitem\u6807\u7b7e<\/p>\n<pre class=\"lang:default decode:true \">\/\/ values-v19\u3002v19 \u5f00\u59cb\u6709 android:windowTranslucentStatus \u8fd9\u4e2a\u5c5e\u6027\r\n&lt;style name=\"TranslucentTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\"&gt;\r\n        &lt;item name=\"android:windowTranslucentStatus\"&gt;true&lt;\/item&gt;\r\n        &lt;item name=\"android:windowTranslucentNavigation\"&gt;true&lt;\/item&gt;\r\n&lt;\/style&gt;\r\n\r\n\/\/ values-v21\u30025.0 \u4ee5\u4e0a\u63d0\u4f9b\u4e86 setStatusBarColor()  \u65b9\u6cd5\u8bbe\u7f6e\u72b6\u6001\u680f\u989c\u8272\u3002\r\n&lt;style name=\"TranslucentTheme\" parent=\"Theme.AppCompat.Light.NoActionBar\"&gt;\r\n    &lt;item name=\"android:windowTranslucentStatus\"&gt;false&lt;\/item&gt;\r\n    &lt;item name=\"android:windowTranslucentNavigation\"&gt;true&lt;\/item&gt;\r\n    &lt;!--Android 5.x\u5f00\u59cb\u9700\u8981\u628a\u989c\u8272\u8bbe\u7f6e\u900f\u660e\uff0c\u5426\u5219\u5bfc\u822a\u680f\u4f1a\u5448\u73b0\u7cfb\u7edf\u9ed8\u8ba4\u7684\u6d45\u7070\u8272--&gt;\r\n    &lt;item name=\"android:statusBarColor\"&gt;@android:color\/transparent&lt;\/item&gt;\r\n&lt;\/style&gt;<\/pre>\n<p>\u51e1\u662f\u5728style.xml\u4e2d \u6709\u5173 windowTranslucentNavigation\u3001windowTranslucentStatus\u3001statusBarColor \u7edf\u7edf\u5220\u6389,\u5168\u90e8\u5220\u6389~<br \/>\n\u56e0\u4e3a \u6211\u4eec\u8981\u901a\u8fc7\u4ee3\u7801\u53bb\u5b9e\u73b0, xml\u4e2d\u7684\u5404\u79cd\u5c5e\u6027\u5168\u90e8\u4e0d\u8981\u5199, \u907f\u514d\u4ee3\u7801\u51fa\u73b0\u4e92\u76f8\u5e72\u6270, \u4f1a\u51fa\u73b0\u5404\u79cd \u4e3a\u5565\u554a\u65e0\u6548\u554a\u7684bug<\/p>\n<p>\u8fd9\u91cc\u6211\u8981\u5410\u69fd\u4e00\u4e0b, \u6211\u6d4f\u89c8\u8fc7\u5f88\u591a\u6587\u7ae0\u535a\u5ba2, \u5173\u4e8e\u72b6\u6001\u680f\u9002\u914d, \u4e00\u4f1a\u513f\u5728java \u8bbe\u7f6esetFitsSystemWindows setStatusBarColor \u4e00\u4f1a\u513f\u53c8\u56de\u5230\u5e03\u5c40\u91cc\u8bbe\u7f6e android:fitsSystemWindows=\u201dxxx\u201d ,\u4e00\u4f1a\u513f\u5728style \u914d\u7f6e android:windowTranslucentStatus\u7b49 \u4e00\u4f1a\u513f\u53c8\u4f7f\u7528\u5de5\u5177\u7c7b \u8bbe\u7f6eFLAG_TRANSLUCENT_NAVIGATION \u2026,\u7136\u540e\u8fd8\u4ec0\u4e484.4 5.x\u5404\u4e00\u4efd style ,\u751a\u81f3\u8fd8\u62ffcolorPrimary\u6765\u4e71\u5165\u4e00\u901a, \u641e\u5f97\u662f\u771f\u7684\u4e71! \u4e0d\u4fe1\u4f60\u770b\u5b8c\u6211\u5199\u7684\u4e4b\u540e\u518d\u53bb\u770b\u522b\u7684, \u6709\u7684\u8bf4\u7684\u4e0d\u5168 \u6bd4\u5982\u6f0f\u4e86\u56fe\u7247\u5982\u4f55\u6c89\u6d78\u6ca1\u8bb2 , \u6216\u8005\u662f\u6f0f\u4e86\u56fe\u7247\u6c89\u6d78\u540e \u5e03\u5c40\u4e5f\u8ddf\u7740\u6c89\u6d78\u8fdb\u72b6\u6001\u680f\u5982\u4f55\u89e3\u51b3\u6ca1\u8bb2\u2026 \u5509\u2026<\/p>\n<p>\u597d\u4e86\u5e72\u6270\u5df2\u5168\u90e8\u53bb\u9664,\u5f00\u59cb\u9002\u914d<\/p>\n<p>\u9996\u5148\u5728Activity \u7684setContentView \u4e0b\u4e00\u884c\u7f16\u5199\u5982\u4e0b\u4ee3\u7801(\u4e00\u822c\u4f60\u53ef\u4ee5\u5199\u5230\u4f60\u7684BaseActivity\u91cc,\u5426\u5219\u4f60\u6bcf\u4e2aactivity\u90fd\u5f97\u5199\u4e00\u6b21)<\/p>\n<pre class=\"lang:default decode:true \">@Override\r\nprotected void onCreate(Bundle savedInstanceState) {\r\n   super.onCreate(savedInstanceState);\r\n   setContentView(R.layout.xxx);\r\n   \/\/\u5f53FitsSystemWindows\u8bbe\u7f6e true \u65f6\uff0c\u4f1a\u5728\u5c4f\u5e55\u6700\u4e0a\u65b9\u9884\u7559\u51fa\u72b6\u6001\u680f\u9ad8\u5ea6\u7684 padding\r\n   StatusBarUtil.setRootViewFitsSystemWindows(this,true);\r\n   \/\/\u8bbe\u7f6e\u72b6\u6001\u680f\u900f\u660e\r\n   StatusBarUtil.setTranslucentStatus(this);\r\n   \/\/\u4e00\u822c\u7684\u624b\u673a\u7684\u72b6\u6001\u680f\u6587\u5b57\u548c\u56fe\u6807\u90fd\u662f\u767d\u8272\u7684, \u53ef\u5982\u679c\u4f60\u7684\u5e94\u7528\u4e5f\u662f\u7eaf\u767d\u8272\u7684, \u6216\u5bfc\u81f4\u72b6\u6001\u680f\u6587\u5b57\u770b\u4e0d\u6e05\r\n   \/\/\u6240\u4ee5\u5982\u679c\u4f60\u662f\u8fd9\u79cd\u60c5\u51b5,\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801, \u8bbe\u7f6e\u72b6\u6001\u4f7f\u7528\u6df1\u8272\u6587\u5b57\u56fe\u6807\u98ce\u683c, \u5426\u5219\u4f60\u53ef\u4ee5\u9009\u62e9\u6027\u6ce8\u91ca\u6389\u8fd9\u4e2aif\u5185\u5bb9\r\n   if (!StatusBarUtil.setStatusBarDarkTheme(this, true)) {\r\n        \/\/\u5982\u679c\u4e0d\u652f\u6301\u8bbe\u7f6e\u6df1\u8272\u98ce\u683c \u4e3a\u4e86\u517c\u5bb9\u603b\u4e0d\u80fd\u8ba9\u72b6\u6001\u680f\u767d\u767d\u7684\u770b\u4e0d\u6e05, \u4e8e\u662f\u8bbe\u7f6e\u4e00\u4e2a\u72b6\u6001\u680f\u989c\u8272\u4e3a\u534a\u900f\u660e,\r\n        \/\/\u8fd9\u6837\u534a\u900f\u660e+\u767d=\u7070, \u72b6\u6001\u680f\u7684\u6587\u5b57\u80fd\u770b\u5f97\u6e05\r\n        StatusBarUtil.setStatusBarColor(this,0x55000000);\r\n   } \r\n}<\/pre>\n<p>\u4e0a\u9762\u5148\u8fd9\u6837 \u7531\u4e8e\u754c\u9762\u98ce\u683c\u5f88\u591a, \u6bd4\u5982\u540c\u4e00\u4e2aapp\u6709 \u7684\u754c\u9762\u662f\u9ed1\u8272\u98ce\u683c\u7684\u9875\u9762, \u6709\u7684\u662f\u767d\u8272\u98ce\u683c\u7684\u9875\u9762,\u6709\u7684\u662f\u9876\u90e8\u662f\u56fe\u7247\u7684\u754c\u9762\u5e0c\u671b\u6c89\u6d78\u8fdb\u53bb \u8fd9\u6837\u66f4\u597d\u770b, \u540c\u65f6 \u6b64\u65f6\u72b6\u6001\u680f\u6587\u5b57\u8981\u8ddf\u968f\u6539\u53d8<\/p>\n<p>\u5176\u5b9e\u90fd\u4e0d\u7528\u6211\u89e3\u91ca\u4e86 \u5c31\u6309\u81ea\u5df1\u9700\u6c42 \u914d\u7f6e\u5457,\u5de5\u5177\u7c7b\u90fd\u5199\u597d\u529f\u80fd\u4e86.<br \/>\n\u6bd4\u5982\u6211\u8fd9\u4e2a 4\u4e2a\u4e0d\u540c\u7684fragment,\u6709\u4e00\u4e2a\u662f\u767d\u8272, \u53e6\u5916\u4e24\u4e2a\u662f\u9876\u90e8\u662f\u56fe\u7247\u7684<br \/>\n\u6211\u662f\u8fd9\u6837\u5207\u6362\u72b6\u6001\u680f\u6587\u5b57\u6df1\u6d45\u8272\u7684,\u4f60\u4eec\u53c2\u8003\u4e0b<br \/>\n0\u754c\u9762\u8bbe\u7f6e\u72b6\u6001\u680f\u9ed1\u8272\u56fe\u6807<br \/>\n<img loading=\"lazy\" class=\"alignnone size-full wp-image-206\" src=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/2018072616084245.png\" alt=\"\" width=\"404\" height=\"106\" srcset=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/2018072616084245.png 404w, https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/2018072616084245-375x98.png 375w\" sizes=\"(max-width: 404px) 100vw, 404px\" alt=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c1\u5f20\" title=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c1\u5f20-Qtvz\" > <img loading=\"lazy\" class=\"alignnone size-full wp-image-208\" src=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726160927887.png\" alt=\"\" width=\"447\" height=\"87\" srcset=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726160927887.png 447w, https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726160927887-375x73.png 375w\" sizes=\"(max-width: 447px) 100vw, 447px\" alt=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c2\u5f20\" title=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c2\u5f20-Qtvz\" ><img loading=\"lazy\" class=\"alignnone size-full wp-image-207\" src=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726160115724.png\" alt=\"\" width=\"1178\" height=\"342\" srcset=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726160115724.png 1178w, https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726160115724-375x109.png 375w, https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726160115724-768x223.png 768w, https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726160115724-960x279.png 960w\" sizes=\"(max-width: 1178px) 100vw, 1178px\" alt=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c3\u5f20\" title=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c3\u5f20-Qtvz\" ><\/p>\n<p>\u4f60\u8fd8\u53ef\u4ee5\u968f\u65f6\u4f7f\u7528<br \/>\nStatusBarUtil.setStatusBarColor(this,\u989c\u8272\u503c);<br \/>\n\u8bbe\u7f6e\u4e0d\u540cfragment\u65f6 \u7684\u72b6\u6001\u680f\u989c\u8272<\/p>\n<p>\u81f3\u6b64 \u4f60\u660e\u767d\u4e86\u8bbe\u7f6e\u72b6\u6001\u680f\u989c\u8272 \u548c \u968f\u754c\u9762\u5207\u6362\u65f6 \u8be5\u600e\u4e48\u6539\u72b6\u6001\u680f\u989c\u8272\u6216\u72b6\u6001\u680f\u6587\u5b57\u989c\u8272, \u8fd9\u4e9b\u90fd\u4e0d\u91cd\u8981, \u56e0\u4e3a\u633a\u7b80\u5355\u7684, \u73b0\u5728\u6765\u4e00\u4e2a\u86cb\u75bc\u7684\u95ee\u9898<\/p>\n<h1 id=\"\u6211\u8981\u628a\u56fe\u7247\u4e5f\u6c89\u6d78\u8fdb\u53bb\">\u6211\u8981\u628a\u56fe\u7247\u4e5f\u6c89\u6d78\u8fdb\u53bb!!!<\/h1>\n<p>\u901a\u5e38 \u4f60\u4f7f\u7528\u6211\u521a\u624d\u7684\u4ee3\u7801\u65f6 \u76f8\u540c\u989c\u8272\u7684\u754c\u9762\u6ca1\u5565\u95ee\u9898,\u6bd4\u5982:<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-209\" src=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726161257816.png\" alt=\"\" width=\"423\" height=\"98\" srcset=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726161257816.png 423w, https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726161257816-375x87.png 375w\" sizes=\"(max-width: 423px) 100vw, 423px\" alt=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c4\u5f20\" title=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c4\u5f20-Qtvz\" ><\/p>\n<p>\u4f46 \u5f53\u4f60\u754c\u9762\u9876\u90e8\u662f\u56fe\u7247\u754c\u9762\u7684\u65f6\u5019 \u6216\u8005 \u6807\u9898\u989c\u8272\u4e0d\u4e00\u6837\u65f6<br \/>\n\u6210\u4e86\u8fd9\u9b3c\u6837\u5b50,<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-210\" src=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726161455116.png\" alt=\"\" width=\"406\" height=\"127\" srcset=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726161455116.png 406w, https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726161455116-375x117.png 375w\" sizes=\"(max-width: 406px) 100vw, 406px\" alt=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c5\u5f20\" title=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c5\u5f20-Qtvz\" ><\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a\u6211\u524d\u9762\u8bbe\u7f6e\u4e86 setRootViewFitsSystemWindows(this,true); \u4e8e\u662f\u5e26\u6709 paddingTop=\u72b6\u6001\u680f\u9ad8\u5ea6 \u7684\u6548\u679c<\/p>\n<p>\u9996\u5148 \u4f60\u53ef\u4ee5\u9009\u62e9\u4e24\u79cd\u5e94\u5bf9\u529e\u6cd5<br \/>\n\u5982\u679c\u9876\u90e8\u4e0d\u662f\u56fe\u7247\u5e03\u5c40 , \u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 setStatusBarColor \u8bbe\u7f6e\u76f8\u540c\u989c\u8272\u5373\u53ef<br \/>\n\u5982\u679c\u9876\u90e8\u662f\u56fe\u7247\u5e03\u5c40, \u90a3\u4e48\u95ee\u9898\u6765\u4e86<br \/>\n\u8fd9\u91cc\u6ce8\u610f\u4e86<\/p>\n<p>\u60f3\u8981\u56fe\u7247\u6c89\u6d78, \u5fc5\u987b\u8bbe\u7f6efitsSystemWindows=false, \u4ee5\u53bb\u6389padding\u6548\u679c, \u7136\u540e\u60f3\u529e\u6cd5 \u628a\u56fe\u7247\u4e0a\u5c42\u7684 \u5176\u4ed6View \u6574\u4f53 paddingTop=\u72b6\u6001\u680f\u9ad8 \u8ba9\u5176\u4ed6View\u5411\u4e0b\u632a\u52a8<br \/>\n\u8fd9\u53e5\u8bdd\u4e00\u5b9a\u8981\u7406\u89e3<br \/>\n,\u73b0\u5728\u8bd5\u8bd5\u5728\u5f53\u524d\u5e26\u56fe\u7247\u7684activity \u91cd\u65b0\u8bbe\u7f6esetRootViewFitsSystemWindows(this,false);<br \/>\n\u6548\u679c\u5982\u4e0b(\u4f60\u4f1a\u53d1\u73b0\u56fe\u6807\u8dd1\u5de6\u8fb9\u4e86, \u8bf7\u65e0\u89c6, \u5c06\u5c31\u770b,\u6211\u662f\u5728\u73b0\u6709\u9879\u76ee\u4e2d\u6f14\u793a\u7684 )<br \/>\n\u53bb\u6389padding\u6548\u679c\u540e \u56fe\u7247\u6c89\u6d78\u4e86! \u4f46\u5185\u5bb9\u8fdb\u5165\u4e86\u72b6\u6001\u680f\u91cc \u88ab\u906e\u6321.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-211\" src=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726162747107.png\" alt=\"\" width=\"367\" height=\"69\" alt=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c6\u5f20\" title=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c6\u5f20-Qtvz\" ><\/p>\n<p>\u90a3, \u600e\u4e48\u4ee5\u6700\u65b9\u4fbf\u7684\u65b9\u5f0f \u8ba9\u6574\u4e2a\u5185\u5bb9\u5e03\u5c40 \u5f80\u4e0b\u632a\u52a8?<\/p>\n<p>\u6709\u5f88\u591a\u6559\u7a0b\u90fd\u662f\u5199\u7684\u662f\u5728\u4ee3\u7801\u91cc findView \u7136\u540e\u8bbe\u7f6epadding , \u5f88\u662f\u9ebb\u70e6, \u8981\u662f\u591a\u4e2a\u754c\u9762\u90fd\u8fd9\u6837 \u4ee3\u7801\u5c82\u6b62\u4e71?<br \/>\n\u66fe\u7ecf\u8bd5\u56fe\u5728xml\u4e2d\u4f7f\u7528 \u72b6\u6001\u680f\u9ad8\u5ea6\u503c ,\u7ed3\u679c\u53d1\u73b0\u8fd9\u662f\u51e0\u4e4e\u662f\u4e0d\u53ef\u80fd\u7684, \u56e0\u4e3a\u7f16\u8bd1\u540e xml\u56fa\u5b9a\u4e86\u503c,\u9664\u975e\u4f7f\u7528\u53cd\u5c04, \u4f46\u8fd9\u5230\u4e86\u5b89\u53539.0\u4e0d\u80fd\u53cd\u5c04\u7cfb\u7edfapi\u600e\u4e48\u529e\u2026<br \/>\n\u4e8e\u662f\u6211\u60f3\u51fa\u4e86\u4e00\u79cd\u89e3\u51b3\u529e\u6cd5<\/p>\n<p>\u81ea\u5b9a\u4e49\u4e00\u4e2aView ,\u7528\u6765\u505a\u72b6\u6001\u680f\u9ad8\u5ea6\u5360\u4f4d<\/p>\n<pre class=\"lang:default decode:true\">\/**\r\n * \u4f5c\u8005:\u4e1c\u829d\r\n * \u529f\u80fd:\u72b6\u6001\u680f\u9ad8\u5ea6View,\u7528\u4e8e\u6c89\u6d78\u5360\u4f4d\r\n *\/\r\n\r\npublic class StatusBarHeightView extends LinearLayout {\r\n    private int statusBarHeight;\r\n    private int type;\r\n\r\n    public StatusBarHeightView(Context context, @Nullable AttributeSet attrs) {\r\n        super(context, attrs);\r\n        init(attrs);\r\n    }\r\n\r\n    public StatusBarHeightView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {\r\n        super(context, attrs, defStyleAttr);\r\n        init(attrs);\r\n    }\r\n\r\n    public StatusBarHeightView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {\r\n        super(context, attrs, defStyleAttr);\r\n        init(attrs);\r\n\r\n\r\n    }\r\n\r\n    private void init(@Nullable AttributeSet attrs) {\r\n\r\n        int resourceId = getResources().getIdentifier(\"status_bar_height\", \"dimen\", \"android\");\r\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {\r\n            if(resourceId&gt;0) {\r\n                statusBarHeight = getResources().getDimensionPixelSize(resourceId);\r\n            }\r\n        }else{\r\n            \/\/\u4f4e\u7248\u672c \u76f4\u63a5\u8bbe\u7f6e0\r\n            statusBarHeight = 0;\r\n        }\r\n        if (attrs != null) {\r\n            TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.StatusBarHeightView);\r\n            type = typedArray.getInt(R.styleable.StatusBarHeightView_use_type, 0);\r\n            typedArray.recycle();\r\n        }\r\n        if (type == 1) {\r\n            setPadding(getPaddingLeft(), statusBarHeight, getPaddingRight(), getPaddingBottom());\r\n        }\r\n    }\r\n\r\n    @Override\r\n    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {\r\n        if (type == 0) {\r\n            setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec),\r\n                    statusBarHeight);\r\n        } else {\r\n            super.onMeasure(widthMeasureSpec, heightMeasureSpec);\r\n        }\r\n    }\r\n\r\n}<\/pre>\n<pre class=\"lang:default decode:true\" title=\"attrs.xml\">    &lt;declare-styleable name=\"StatusBarHeightView\"&gt;\r\n        &lt;attr name=\"use_type\" format=\"integer\"&gt;\r\n            &lt;enum name=\"use_height\" value=\"0\" \/&gt;\r\n            &lt;enum name=\"use_padding_top\" value=\"1\" \/&gt;\r\n        &lt;\/attr&gt;\r\n    &lt;\/declare-styleable&gt;<\/pre>\n<p>\u4ee3\u7801\u5f88\u7b80\u5355, \u5c31\u662f\u5199\u4e00\u4e2aView, \u652f\u6301paddingTop= \u72b6\u6001\u680f\u9ad8\u5ea6\u503c \u7684View,<br \/>\n\u89e3\u91ca\u4e0b\u4e24\u4e2a\u7c7b\u578b:<br \/>\nuse_height: \u8bbe\u7f6e\u5f53\u524d\u5e03\u5c40\u9ad8\u5ea6=\u72b6\u6001\u680f\u9ad8\u5ea6\u503c \u7528\u4e8e\u65e0\u5b50View\u65f6\u7684\u5360\u4f4d<br \/>\nuse_padding_top: \u8bbe\u7f6e\u5f53\u524d\u9876\u90e8padding=\u72b6\u6001\u680f\u9ad8\u5ea6\u503c \u7528\u4e8e\u6709\u5b50View\u65f6\u7684\u5360\u4f4d<br \/>\n\u9002\u914d\u4f4e\u4e8e4.4\u65f6 \u5360\u4f4dView\u7684\u9ad8\u5ea6\u4e3a0 \u6240\u4ee5\u4e0d\u53ef\u89c1<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5, \u7528StatusBarHeightView \u6765\u5305\u4f4f\u4f60\u8981\u5f80\u4e0b\u79fb\u52a8\u7684\u5185\u5bb9! \u5355\u72ec\u7559\u51fa\u8981\u6c89\u6d78\u7684View\u4e0d\u5305\u4f4f,<br \/>\n\u4e3e\u4f8b:<\/p>\n<pre class=\"lang:default decode:true \">&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\r\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\n    android:layout_width=\"match_parent\"\r\n    android:layout_height=\"match_parent\"\r\n    &gt;       \r\n     &lt;!--\u9876\u90e8\u7684\u9700\u8981\u6c89\u6d78\u7684\u56fe\u7247View \u6216\u5176\u4ed6\u4e1c\u897f \u89c6\u9891View  \u7b49 --&gt;     \r\n     &lt;ImageView\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\"\r\n        android:background=\"@mipmap\/icon_top_bg\"\r\n        android:scaleType=\"centerCrop\" \/&gt;\r\n\r\n&lt;!-- app:use_type=\"use_padding_top \u5411\u4e0apaddingTop\u72b6\u6001\u680f\u9ad8\u5ea6--&gt;\r\n    &lt;com.xxx.views.StatusBarHeightView\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_alignParentEnd=\"true\"\r\n        android:layout_marginEnd=\"@dimen\/widget_size_5\"\r\n        app:use_type=\"use_padding_top\"\r\n        android:orientation=\"vertical\" &gt;\r\n         &lt;!--\u8fd9\u91cc\u653e\u5185\u5bb9\u5e03\u5c40\u6216View--&gt;\r\n         &lt;ImageView\r\n              android:id=\"@+id\/ivUserShare\"\r\n              android:layout_width=\"@dimen\/title_height\"\r\n              android:layout_height=\"@dimen\/title_height\"\r\n              android:padding=\"@dimen\/widget_size_10\"\r\n              android:src=\"@mipmap\/icon_share_white\" \/&gt;\r\n\r\n    &lt;\/com.xxx.views.StatusBarHeightView&gt;\r\n&lt;\/RelativeLayout&gt;<\/pre>\n<pre class=\"lang:default decode:true \">\/\/\u4e0d\u8981\u5fd8\u8bb0\u4e86, \u5728\u5f53\u524dactivity onCreate\u4e2d\u8bbe\u7f6e \u53d6\u6d88padding,  \u56e0\u4e3a\u8fd9\u4e2apadding \u6211\u4eec\u7528\u4ee3\u7801\u5b9e\u73b0\u4e86,\u4e0d\u9700\u8981\u7cfb\u7edf\u5e2e\u6211\r\nStatusBarUtil.setRootViewFitsSystemWindows(this,false);<\/pre>\n<p>ava \u4ee3\u7801\u8fd9\u8fb9\u4e0d\u9700\u8981\u6539\u52a8, \u8fd0\u884capp\u5373\u53ef.<br \/>\n\u5b8c\u7f8e!\u00a0<img loading=\"lazy\" class=\"alignnone size-full wp-image-212\" src=\"https:\/\/qtvz.com\/wp-content\/uploads\/2018\/12\/20180726165927998.png\" alt=\"\" width=\"363\" height=\"91\" alt=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c7\u5f20\" title=\"Android \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u5b8c\u7f8e\u89e3\u51b3\u65b9\u6848 Android\u4ee3\u7801 \u7b2c7\u5f20-Qtvz\" ><\/p>\n<p>\u7ed3\u675f<br \/>\n\u503c\u5f97\u6ce8\u610f\u7684\u662f \u5982\u679c\u4f60\u6309\u6211\u90a3\u6837\u53bb\u505a, \u72b6\u6001\u680f\u989c\u8272\u65e0\u6cd5\u88ab\u4fee\u6539, \u8bf7\u68c0\u67e5\u4e0a\u5c42\u5e03\u5c40\u662f\u5426\u8bbe\u7f6e\u4e86\u80cc\u666f<br \/>\n\u6216\u8005\u53d7\u4e86\u5168\u5c40\u4e3b\u9898\u7684<\/p>\n<pre class=\"lang:default decode:true\">&lt;item name=\"android:windowBackground\"&gt;@color\/xxx&lt;\/item&gt;<\/pre>\n<p>\u7684\u989c\u8272\u5f71\u54cd<\/p>\n<p>\u597d\u4e86,\u53ef\u80fd\u6709\u4e0d\u5bf9\u7684\u5730\u65b9\u671b\u6307\u51fa, \u6216\u51fa\u73b0\u4efb\u4f55\u517c\u5bb9\u6027\u9002\u914d\u95ee\u9898 \u6b22\u8fce\u5728\u4e0b\u65b9\u8bc4\u8bba<\/p>\n<p>================================================================<\/p>\n<p>================================================================<\/p>\n<p>\u8865\u5145:<br \/>\n================================================================<\/p>\n<p>================================================================\u00a0 \u00a0 \u00a0\u6f0f\u4e86\u4e2aRom\u7c7b\u578b\u5224\u65ad\u7684\u5de5\u5177\u7c7b,\u73b0\u5728\u8d34\u4e0a<\/p>\n<pre class=\"lang:default decode:true \" title=\"OSUtils\">public class OSUtils {\r\n\r\n    public static final String ROM_MIUI = \"MIUI\";\r\n    public static final String ROM_EMUI = \"EMUI\";\r\n    public static final String ROM_FLYME = \"FLYME\";\r\n    public static final String ROM_OPPO = \"OPPO\";\r\n    public static final String ROM_SMARTISAN = \"SMARTISAN\";\r\n    public static final String ROM_VIVO = \"VIVO\";\r\n    public static final String ROM_QIKU = \"QIKU\";\r\n\r\n    private static final String KEY_VERSION_MIUI = \"ro.miui.ui.version.name\";\r\n    private static final String KEY_VERSION_EMUI = \"ro.build.version.emui\";\r\n    private static final String KEY_VERSION_OPPO = \"ro.build.version.opporom\";\r\n    private static final String KEY_VERSION_SMARTISAN = \"ro.smartisan.version\";\r\n    private static final String KEY_VERSION_VIVO = \"ro.vivo.os.version\";\r\n\r\n    private static String sName;\r\n    private static String sVersion;\r\n\r\n    public static boolean isEmui() {\r\n        return check(ROM_EMUI);\r\n    }\r\n\r\n    public static boolean isMiui() {\r\n        return check(ROM_MIUI);\r\n    }\r\n\r\n    public static boolean isVivo() {\r\n        return check(ROM_VIVO);\r\n    }\r\n\r\n    public static boolean isOppo() {\r\n        return check(ROM_OPPO);\r\n    }\r\n\r\n    public static boolean isFlyme() {\r\n        return check(ROM_FLYME);\r\n    }\r\n\r\n    public static boolean is360() {\r\n        return check(ROM_QIKU) || check(\"360\");\r\n    }\r\n\r\n    public static boolean isSmartisan() {\r\n        return check(ROM_SMARTISAN);\r\n    }\r\n\r\n    public static String getName() {\r\n        if (sName == null) {\r\n            check(\"\");\r\n        }\r\n        return sName;\r\n    }\r\n\r\n    public static String getVersion() {\r\n        if (sVersion == null) {\r\n            check(\"\");\r\n        }\r\n        return sVersion;\r\n    }\r\n\r\n    public static boolean check(String rom) {\r\n        if (sName != null) {\r\n            return sName.equals(rom);\r\n        }\r\n\r\n        if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_MIUI))) {\r\n            sName = ROM_MIUI;\r\n        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_EMUI))) {\r\n            sName = ROM_EMUI;\r\n        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_OPPO))) {\r\n            sName = ROM_OPPO;\r\n        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_VIVO))) {\r\n            sName = ROM_VIVO;\r\n        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_SMARTISAN))) {\r\n            sName = ROM_SMARTISAN;\r\n        } else {\r\n            sVersion = Build.DISPLAY;\r\n            if (sVersion.toUpperCase().contains(ROM_FLYME)) {\r\n                sName = ROM_FLYME;\r\n            } else {\r\n                sVersion = Build.UNKNOWN;\r\n                sName = Build.MANUFACTURER.toUpperCase();\r\n            }\r\n        }\r\n        return sName.equals(rom);\r\n    }\r\n\r\n    public static String getProp(String name) {\r\n        String line = null;\r\n        BufferedReader input = null;\r\n        try {\r\n            Process p = Runtime.getRuntime().exec(\"getprop \" + name);\r\n            input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);\r\n            line = input.readLine();\r\n            input.close();\r\n        } catch (IOException ex) {\r\n            return null;\r\n        } finally {\r\n            if (input != null) {\r\n                try {\r\n                    input.close();\r\n                } catch (IOException e) {\r\n                    e.printStackTrace();\r\n                }\r\n            }\r\n        }\r\n        return line;\r\n    }\r\n}<\/pre>\n<pre class=\"lang:default decode:true  \" title=\"SystemBarTintManager\">import android.annotation.SuppressLint;\r\nimport android.annotation.TargetApi;\r\nimport android.app.Activity;\r\nimport android.content.Context;\r\nimport android.content.res.Configuration;\r\nimport android.content.res.Resources;\r\nimport android.content.res.TypedArray;\r\nimport android.graphics.drawable.Drawable;\r\nimport android.os.Build;\r\nimport android.util.DisplayMetrics;\r\nimport android.util.TypedValue;\r\nimport android.view.Gravity;\r\nimport android.view.View;\r\nimport android.view.ViewConfiguration;\r\nimport android.view.ViewGroup;\r\nimport android.view.Window;\r\nimport android.view.WindowManager;\r\nimport android.widget.FrameLayout.LayoutParams;\r\n\r\nimport java.lang.reflect.Method;\r\n\r\n\/**\r\n * Class to manage status and navigation bar tint effects when using KitKat\r\n * translucent system UI modes.\r\n *\r\n *\/\r\npublic class SystemBarTintManager {\r\n\r\n    static {\r\n        \/\/ Android allows a system property to override the presence of the navigation bar.\r\n        \/\/ Used by the emulator.\r\n        \/\/ See https:\/\/github.com\/android\/platform_frameworks_base\/blob\/master\/policy\/src\/com\/android\/internal\/policy\/impl\/PhoneWindowManager.java#L1076\r\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {\r\n            try {\r\n                Class c = Class.forName(\"android.os.SystemProperties\");\r\n                Method m = c.getDeclaredMethod(\"get\", String.class);\r\n                m.setAccessible(true);\r\n                sNavBarOverride = (String) m.invoke(null, \"qemu.hw.mainkeys\");\r\n            } catch (Throwable e) {\r\n                sNavBarOverride = null;\r\n            }\r\n        }\r\n    }\r\n\r\n\r\n    \/**\r\n     * The default system bar tint color value.\r\n     *\/\r\n    public static final int DEFAULT_TINT_COLOR = 0x99000000;\r\n\r\n    private static String sNavBarOverride;\r\n\r\n    private final SystemBarConfig mConfig;\r\n    private boolean mStatusBarAvailable;\r\n    private boolean mNavBarAvailable;\r\n    private boolean mStatusBarTintEnabled;\r\n    private boolean mNavBarTintEnabled;\r\n    private View mStatusBarTintView;\r\n    private View mNavBarTintView;\r\n\r\n    \/**\r\n     * Constructor. Call this in the host activity onCreate method after its\r\n     * content view has been set. You should always create new instances when\r\n     * the host activity is recreated.\r\n     *\r\n     * @param activity The host activity.\r\n     *\/\r\n    @SuppressLint(\"ResourceType\")\r\n    @TargetApi(19)\r\n    public SystemBarTintManager(Activity activity) {\r\n\r\n        Window win = activity.getWindow();\r\n        ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();\r\n\r\n        if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.KITKAT) {\r\n            \/\/ check theme attrs\r\n            int[] attrs = {android.R.attr.windowTranslucentStatus,\r\n                    android.R.attr.windowTranslucentNavigation};\r\n            TypedArray a = activity.obtainStyledAttributes(attrs);\r\n            try {\r\n                mStatusBarAvailable = a.getBoolean(0, false);\r\n                mNavBarAvailable = a.getBoolean(1, false);\r\n            } finally {\r\n                a.recycle();\r\n            }\r\n\r\n            \/\/ check window flags\r\n            WindowManager.LayoutParams winParams = win.getAttributes();\r\n            int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;\r\n            if ((winParams.flags &amp; bits) != 0) {\r\n                mStatusBarAvailable = true;\r\n            }\r\n            bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;\r\n            if ((winParams.flags &amp; bits) != 0) {\r\n                mNavBarAvailable = true;\r\n            }\r\n        }\r\n\r\n        mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);\r\n        \/\/ device might not have virtual navigation keys\r\n        if (!mConfig.hasNavigtionBar()) {\r\n            mNavBarAvailable = false;\r\n        }\r\n\r\n        if (mStatusBarAvailable) {\r\n            setupStatusBarView(activity, decorViewGroup);\r\n        }\r\n        if (mNavBarAvailable) {\r\n            setupNavBarView(activity, decorViewGroup);\r\n        }\r\n\r\n    }\r\n\r\n    \/**\r\n     * Enable tinting of the system status bar.\r\n     *\r\n     * If the platform is running Jelly Bean or earlier, or translucent system\r\n     * UI modes have not been enabled in either the theme or via window flags,\r\n     * then this method does nothing.\r\n     *\r\n     * @param enabled True to enable tinting, false to disable it (default).\r\n     *\/\r\n    public void setStatusBarTintEnabled(boolean enabled) {\r\n        mStatusBarTintEnabled = enabled;\r\n        if (mStatusBarAvailable) {\r\n            mStatusBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Enable tinting of the system navigation bar.\r\n     *\r\n     * If the platform does not have soft navigation keys, is running Jelly Bean\r\n     * or earlier, or translucent system UI modes have not been enabled in either\r\n     * the theme or via window flags, then this method does nothing.\r\n     *\r\n     * @param enabled True to enable tinting, false to disable it (default).\r\n     *\/\r\n    public void setNavigationBarTintEnabled(boolean enabled) {\r\n        mNavBarTintEnabled = enabled;\r\n        if (mNavBarAvailable) {\r\n            mNavBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified color tint to all system UI bars.\r\n     *\r\n     * @param color The color of the background tint.\r\n     *\/\r\n    public void setTintColor(int color) {\r\n        setStatusBarTintColor(color);\r\n        setNavigationBarTintColor(color);\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified drawable or color resource to all system UI bars.\r\n     *\r\n     * @param res The identifier of the resource.\r\n     *\/\r\n    public void setTintResource(int res) {\r\n        setStatusBarTintResource(res);\r\n        setNavigationBarTintResource(res);\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified drawable to all system UI bars.\r\n     *\r\n     * @param drawable The drawable to use as the background, or null to remove it.\r\n     *\/\r\n    public void setTintDrawable(Drawable drawable) {\r\n        setStatusBarTintDrawable(drawable);\r\n        setNavigationBarTintDrawable(drawable);\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified alpha to all system UI bars.\r\n     *\r\n     * @param alpha The alpha to use\r\n     *\/\r\n    public void setTintAlpha(float alpha) {\r\n        setStatusBarAlpha(alpha);\r\n        setNavigationBarAlpha(alpha);\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified color tint to the system status bar.\r\n     *\r\n     * @param color The color of the background tint.\r\n     *\/\r\n    public void setStatusBarTintColor(int color) {\r\n        if (mStatusBarAvailable) {\r\n            mStatusBarTintView.setBackgroundColor(color);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified drawable or color resource to the system status bar.\r\n     *\r\n     * @param res The identifier of the resource.\r\n     *\/\r\n    public void setStatusBarTintResource(int res) {\r\n        if (mStatusBarAvailable) {\r\n            mStatusBarTintView.setBackgroundResource(res);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified drawable to the system status bar.\r\n     *\r\n     * @param drawable The drawable to use as the background, or null to remove it.\r\n     *\/\r\n    @SuppressWarnings(\"deprecation\")\r\n    public void setStatusBarTintDrawable(Drawable drawable) {\r\n        if (mStatusBarAvailable) {\r\n            mStatusBarTintView.setBackgroundDrawable(drawable);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified alpha to the system status bar.\r\n     *\r\n     * @param alpha The alpha to use\r\n     *\/\r\n    @TargetApi(11)\r\n    public void setStatusBarAlpha(float alpha) {\r\n        if (mStatusBarAvailable &amp;&amp; Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {\r\n            mStatusBarTintView.setAlpha(alpha);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified color tint to the system navigation bar.\r\n     *\r\n     * @param color The color of the background tint.\r\n     *\/\r\n    public void setNavigationBarTintColor(int color) {\r\n        if (mNavBarAvailable) {\r\n            mNavBarTintView.setBackgroundColor(color);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified drawable or color resource to the system navigation bar.\r\n     *\r\n     * @param res The identifier of the resource.\r\n     *\/\r\n    public void setNavigationBarTintResource(int res) {\r\n        if (mNavBarAvailable) {\r\n            mNavBarTintView.setBackgroundResource(res);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified drawable to the system navigation bar.\r\n     *\r\n     * @param drawable The drawable to use as the background, or null to remove it.\r\n     *\/\r\n    @SuppressWarnings(\"deprecation\")\r\n    public void setNavigationBarTintDrawable(Drawable drawable) {\r\n        if (mNavBarAvailable) {\r\n            mNavBarTintView.setBackgroundDrawable(drawable);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Apply the specified alpha to the system navigation bar.\r\n     *\r\n     * @param alpha The alpha to use\r\n     *\/\r\n    @TargetApi(11)\r\n    public void setNavigationBarAlpha(float alpha) {\r\n        if (mNavBarAvailable &amp;&amp; Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {\r\n            mNavBarTintView.setAlpha(alpha);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Get the system bar configuration.\r\n     *\r\n     * @return The system bar configuration for the current device configuration.\r\n     *\/\r\n    public SystemBarConfig getConfig() {\r\n        return mConfig;\r\n    }\r\n\r\n    \/**\r\n     * Is tinting enabled for the system status bar?\r\n     *\r\n     * @return True if enabled, False otherwise.\r\n     *\/\r\n    public boolean isStatusBarTintEnabled() {\r\n        return mStatusBarTintEnabled;\r\n    }\r\n\r\n    \/**\r\n     * Is tinting enabled for the system navigation bar?\r\n     *\r\n     * @return True if enabled, False otherwise.\r\n     *\/\r\n    public boolean isNavBarTintEnabled() {\r\n        return mNavBarTintEnabled;\r\n    }\r\n\r\n    private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {\r\n        mStatusBarTintView = new View(context);\r\n        LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());\r\n        params.gravity = Gravity.TOP;\r\n        if (mNavBarAvailable &amp;&amp; !mConfig.isNavigationAtBottom()) {\r\n            params.rightMargin = mConfig.getNavigationBarWidth();\r\n        }\r\n        mStatusBarTintView.setLayoutParams(params);\r\n        mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);\r\n        mStatusBarTintView.setVisibility(View.GONE);\r\n        decorViewGroup.addView(mStatusBarTintView);\r\n    }\r\n\r\n    private void setupNavBarView(Context context, ViewGroup decorViewGroup) {\r\n        mNavBarTintView = new View(context);\r\n        LayoutParams params;\r\n        if (mConfig.isNavigationAtBottom()) {\r\n            params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getNavigationBarHeight());\r\n            params.gravity = Gravity.BOTTOM;\r\n        } else {\r\n            params = new LayoutParams(mConfig.getNavigationBarWidth(), LayoutParams.MATCH_PARENT);\r\n            params.gravity = Gravity.RIGHT;\r\n        }\r\n        mNavBarTintView.setLayoutParams(params);\r\n        mNavBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);\r\n        mNavBarTintView.setVisibility(View.GONE);\r\n        decorViewGroup.addView(mNavBarTintView);\r\n    }\r\n\r\n    \/**\r\n     * Class which describes system bar sizing and other characteristics for the current\r\n     * device configuration.\r\n     *\r\n     *\/\r\n    public static class SystemBarConfig {\r\n\r\n        private static final String STATUS_BAR_HEIGHT_RES_NAME = \"status_bar_height\";\r\n        private static final String NAV_BAR_HEIGHT_RES_NAME = \"navigation_bar_height\";\r\n        private static final String NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME = \"navigation_bar_height_landscape\";\r\n        private static final String NAV_BAR_WIDTH_RES_NAME = \"navigation_bar_width\";\r\n        private static final String SHOW_NAV_BAR_RES_NAME = \"config_showNavigationBar\";\r\n\r\n        private final boolean mTranslucentStatusBar;\r\n        private final boolean mTranslucentNavBar;\r\n        private final int mStatusBarHeight;\r\n        private final int mActionBarHeight;\r\n        private final boolean mHasNavigationBar;\r\n        private final int mNavigationBarHeight;\r\n        private final int mNavigationBarWidth;\r\n        private final boolean mInPortrait;\r\n        private final float mSmallestWidthDp;\r\n\r\n        private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) {\r\n            Resources res = activity.getResources();\r\n            mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);\r\n            mSmallestWidthDp = getSmallestWidthDp(activity);\r\n            mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);\r\n            mActionBarHeight = getActionBarHeight(activity);\r\n            mNavigationBarHeight = getNavigationBarHeight(activity);\r\n            mNavigationBarWidth = getNavigationBarWidth(activity);\r\n            mHasNavigationBar = (mNavigationBarHeight &gt; 0);\r\n            mTranslucentStatusBar = translucentStatusBar;\r\n            mTranslucentNavBar = traslucentNavBar;\r\n        }\r\n\r\n        @TargetApi(14)\r\n        private int getActionBarHeight(Context context) {\r\n            int result = 0;\r\n            if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {\r\n                TypedValue tv = new TypedValue();\r\n                context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);\r\n                result = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());\r\n            }\r\n            return result;\r\n        }\r\n\r\n        @TargetApi(14)\r\n        private int getNavigationBarHeight(Context context) {\r\n            Resources res = context.getResources();\r\n            int result = 0;\r\n            if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {\r\n                if (hasNavBar(context)) {\r\n                    String key;\r\n                    if (mInPortrait) {\r\n                        key = NAV_BAR_HEIGHT_RES_NAME;\r\n                    } else {\r\n                        key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME;\r\n                    }\r\n                    return getInternalDimensionSize(res, key);\r\n                }\r\n            }\r\n            return result;\r\n        }\r\n\r\n        @TargetApi(14)\r\n        private int getNavigationBarWidth(Context context) {\r\n            Resources res = context.getResources();\r\n            int result = 0;\r\n            if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {\r\n                if (hasNavBar(context)) {\r\n                    return getInternalDimensionSize(res, NAV_BAR_WIDTH_RES_NAME);\r\n                }\r\n            }\r\n            return result;\r\n        }\r\n\r\n        @TargetApi(14)\r\n        private boolean hasNavBar(Context context) {\r\n            Resources res = context.getResources();\r\n            int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, \"bool\", \"android\");\r\n            if (resourceId != 0) {\r\n                boolean hasNav = res.getBoolean(resourceId);\r\n                \/\/ check override flag (see static block)\r\n                if (\"1\".equals(sNavBarOverride)) {\r\n                    hasNav = false;\r\n                } else if (\"0\".equals(sNavBarOverride)) {\r\n                    hasNav = true;\r\n                }\r\n                return hasNav;\r\n            } else { \/\/ fallback\r\n                return !ViewConfiguration.get(context).hasPermanentMenuKey();\r\n            }\r\n        }\r\n\r\n        private int getInternalDimensionSize(Resources res, String key) {\r\n            int result = 0;\r\n            int resourceId = res.getIdentifier(key, \"dimen\", \"android\");\r\n            if (resourceId &gt; 0) {\r\n                result = res.getDimensionPixelSize(resourceId);\r\n            }\r\n            return result;\r\n        }\r\n\r\n        @SuppressLint(\"NewApi\")\r\n        private float getSmallestWidthDp(Activity activity) {\r\n            DisplayMetrics metrics = new DisplayMetrics();\r\n            if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN) {\r\n                activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);\r\n            } else {\r\n                \/\/ TODO this is not correct, but we don't really care pre-kitkat\r\n                activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);\r\n            }\r\n            float widthDp = metrics.widthPixels \/ metrics.density;\r\n            float heightDp = metrics.heightPixels \/ metrics.density;\r\n            return Math.min(widthDp, heightDp);\r\n        }\r\n\r\n        \/**\r\n         * Should a navigation bar appear at the bottom of the screen in the current\r\n         * device configuration? A navigation bar may appear on the right side of\r\n         * the screen in certain configurations.\r\n         *\r\n         * @return True if navigation should appear at the bottom of the screen, False otherwise.\r\n         *\/\r\n        public boolean isNavigationAtBottom() {\r\n            return (mSmallestWidthDp &gt;= 600 || mInPortrait);\r\n        }\r\n\r\n        \/**\r\n         * Get the height of the system status bar.\r\n         *\r\n         * @return The height of the status bar (in pixels).\r\n         *\/\r\n        public int getStatusBarHeight() {\r\n            return mStatusBarHeight;\r\n        }\r\n\r\n        \/**\r\n         * Get the height of the action bar.\r\n         *\r\n         * @return The height of the action bar (in pixels).\r\n         *\/\r\n        public int getActionBarHeight() {\r\n            return mActionBarHeight;\r\n        }\r\n\r\n        \/**\r\n         * Does this device have a system navigation bar?\r\n         *\r\n         * @return True if this device uses soft key navigation, False otherwise.\r\n         *\/\r\n        public boolean hasNavigtionBar() {\r\n            return mHasNavigationBar;\r\n        }\r\n\r\n        \/**\r\n         * Get the height of the system navigation bar.\r\n         *\r\n         * @return The height of the navigation bar (in pixels). If the device does not have\r\n         * soft navigation keys, this will always return 0.\r\n         *\/\r\n        public int getNavigationBarHeight() {\r\n            return mNavigationBarHeight;\r\n        }\r\n\r\n        \/**\r\n         * Get the width of the system navigation bar when it is placed vertically on the screen.\r\n         *\r\n         * @return The width of the navigation bar (in pixels). If the device does not have\r\n         * soft navigation keys, this will always return 0.\r\n         *\/\r\n        public int getNavigationBarWidth() {\r\n            return mNavigationBarWidth;\r\n        }\r\n\r\n        \/**\r\n         * Get the layout inset for any system UI that appears at the top of the screen.\r\n         *\r\n         * @param withActionBar True to include the height of the action bar, False otherwise.\r\n         * @return The layout inset (in pixels).\r\n         *\/\r\n        public int getPixelInsetTop(boolean withActionBar) {\r\n            return (mTranslucentStatusBar ? mStatusBarHeight : 0) + (withActionBar ? mActionBarHeight : 0);\r\n        }\r\n\r\n        \/**\r\n         * Get the layout inset for any system UI that appears at the bottom of the screen.\r\n         *\r\n         * @return The layout inset (in pixels).\r\n         *\/\r\n        public int getPixelInsetBottom() {\r\n            if (mTranslucentNavBar &amp;&amp; isNavigationAtBottom()) {\r\n                return mNavigationBarHeight;\r\n            } else {\r\n                return 0;\r\n            }\r\n        }\r\n\r\n        \/**\r\n         * Get the layout inset for any system UI that appears at the right of the screen.\r\n         *\r\n         * @return The layout inset (in pixels).\r\n         *\/\r\n        public int getPixelInsetRight() {\r\n            if (mTranslucentNavBar &amp;&amp; !isNavigationAtBottom()) {\r\n                return mNavigationBarWidth;\r\n            } else {\r\n                return 0;\r\n            }\r\n        }\r\n\r\n    }\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<!--wp-compress-html no compression--><!--wp-compress-html-->","protected":false},"excerpt":{"rendered":"\u6ce8\u660e\u4e0b,\u8fd9\u91cc\u53ea\u8bb2\u72b6\u6001\u680f,\u5bfc\u822a\u680f\u540e\u9762\u770b\u6709\u6ca1\u6709\u5fc5\u8981\u518d\u8bb2 \u56fd\u5185\u5f88\u591a\u7c7b\u4f3c\u7684\u6587\u7ae0, \u6211\u53ea\u60f3\u8bf4\u4e00\u4e2a\u5b57, \u771ftm\u4e71! \u6211\u770b\u4e0d\u61c2\u2026 \u8bc4\u8bba\u91cc\u9762 \u5168\u5728\u8bf4\u65e0\u6548\u4ec0\u4e48\u7684 (\u6211\u8bd5\u4e86\u4e5f\u65e0\u6548, \u597d\u5389\u5bb3\u7684\u6837\u5b50) \u4e0d\u5e9f\u8bdd,\u56de\u5230\u6b63\u9898, \u9996 \u00b7\u00b7\u00b7","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[41],"tags":[64],"views":12998,"_links":{"self":[{"href":"https:\/\/qtvz.com\/api\/wp\/v2\/posts\/205"}],"collection":[{"href":"https:\/\/qtvz.com\/api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qtvz.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/comments?post=205"}],"version-history":[{"count":1,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/posts\/205\/revisions"}],"predecessor-version":[{"id":213,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/posts\/205\/revisions\/213"}],"wp:attachment":[{"href":"https:\/\/qtvz.com\/api\/wp\/v2\/media?parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/categories?post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qtvz.com\/api\/wp\/v2\/tags?post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}