安卓实现沉浸式效果,状态栏变色

  1. 原创作品,未经允许禁止转载,转载请注明来自:http://www.cnblogs.com/jiangbeixiaoqiao/
  2. <span style="font-size:24px;">这几天研究沉浸模式,多种方法,目前觉得今天的这种方法最靠谱,android4.4以上都可以实现此效果,个人感觉并不是沉浸模式,原理只是将状态栏更改了颜色,且加上了半透明效果,而且效果和QQ等基本一样。  
  3. 1.调用如下代码  
  4. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){  
  5.            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);  
  6.            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);  
  7.            SystemBarTintManager tintManager = new SystemBarTintManager(this);  
  8.            tintManager.setStatusBarTintColor(getResources().getColor(R.color.pink));  
  9.            tintManager.setStatusBarTintEnabled(true);  
  10. 2.在布局文件的跟布局中添加如下属性  
  11. android:fitsSystemWindows="true"  
  12. 或者更改主题 stytle  
  13. <item name="android:fitsSystemWindows">true</item>  
  14. 3.导入SystemBarTintManager 类  
  15.   
  16.   
  17. package cn.doolii.usershopping.base;  
  18.   
  19.   
  20. import android.annotation.SuppressLint;  
  21. import android.annotation.TargetApi;  
  22. import android.app.Activity;  
  23. import android.content.Context;  
  24. import android.content.res.Configuration;  
  25. import android.content.res.Resources;  
  26. import android.content.res.TypedArray;  
  27. import android.graphics.drawable.Drawable;  
  28. import android.os.Build;  
  29. import android.util.DisplayMetrics;  
  30. import android.util.TypedValue;  
  31. import android.view.Gravity;  
  32. import android.view.View;  
  33. import android.view.ViewConfiguration;  
  34. import android.view.ViewGroup;  
  35. import android.view.Window;  
  36. import android.view.WindowManager;  
  37. import android.widget.FrameLayout.LayoutParams;  
  38.   
  39.   
  40. import java.lang.reflect.Method;  
  41.   
  42.   
  43. /** 
  44.  * Class to manage status and navigation bar tint effects when using KitKat  
  45.  * translucent system UI modes. 
  46.  * 
  47.  */  
  48. public class SystemBarTintManager {  
  49.   
  50.   
  51.     static {  
  52.         // Android allows a system property to override the presence of the navigation bar.  
  53.         // Used by the emulator.  
  54.         // See https://github.com/android/platform_frameworks_base/blob/master/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#L1076  
  55.         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {  
  56.             try {  
  57.                 Class c = Class.forName("android.os.SystemProperties");  
  58.                 Method m = c.getDeclaredMethod("get", String.class);  
  59.                 m.setAccessible(true);  
  60.                 sNavBarOverride = (String) m.invoke(null"qemu.hw.mainkeys");  
  61.             } catch (Throwable e) {  
  62.                 sNavBarOverride = null;  
  63.             }  
  64.         }  
  65.     }  
  66.   
  67.   
  68.   
  69.   
  70.     /** 
  71.      * The default system bar tint color value. 
  72.      */  
  73.     public static final int DEFAULT_TINT_COLOR = 0x99000000;  
  74.   
  75.   
  76.     private static String sNavBarOverride;  
  77.   
  78.   
  79.     private final SystemBarConfig mConfig;  
  80.     private boolean mStatusBarAvailable;  
  81.     private boolean mNavBarAvailable;  
  82.     private boolean mStatusBarTintEnabled;  
  83.     private boolean mNavBarTintEnabled;  
  84.     private View mStatusBarTintView;  
  85.     private View mNavBarTintView;  
  86.   
  87.   
  88.     /** 
  89.      * Constructor. Call this in the host activity onCreate method after its 
  90.      * content view has been set. You should always create new instances when 
  91.      * the host activity is recreated. 
  92.      * 
  93.      * @param activity The host activity. 
  94.      */  
  95.     @TargetApi(19)  
  96.     public SystemBarTintManager(Activity activity) {  
  97.   
  98.   
  99.         Window win = activity.getWindow();  
  100.         ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();  
  101.   
  102.   
  103.         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {  
  104.             // check theme attrs  
  105.             int[] attrs = {android.R.attr.windowTranslucentStatus,  
  106.                     android.R.attr.windowTranslucentNavigation};  
  107.             TypedArray a = activity.obtainStyledAttributes(attrs);  
  108.             try {  
  109.                 mStatusBarAvailable = a.getBoolean(0false);  
  110.                 mNavBarAvailable = a.getBoolean(1false);  
  111.             } finally {  
  112.                 a.recycle();  
  113.             }  
  114.   
  115.   
  116.             // check window flags  
  117.             WindowManager.LayoutParams winParams = win.getAttributes();  
  118.             int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;  
  119.             if ((winParams.flags & bits) != 0) {  
  120.                 mStatusBarAvailable = true;  
  121.             }  
  122.             bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;  
  123.             if ((winParams.flags & bits) != 0) {  
  124.                 mNavBarAvailable = true;  
  125.             }  
  126.         }  
  127.   
  128.   
  129.         mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);  
  130.         // device might not have virtual navigation keys  
  131.         if (!mConfig.hasNavigtionBar()) {  
  132.             mNavBarAvailable = false;  
  133.         }  
  134.   
  135.   
  136.         if (mStatusBarAvailable) {  
  137.             setupStatusBarView(activity, decorViewGroup);  
  138.         }  
  139.         if (mNavBarAvailable) {  
  140.             setupNavBarView(activity, decorViewGroup);  
  141.         }  
  142.   
  143.   
  144.     }  
  145.   
  146.   
  147.     /** 
  148.      * Enable tinting of the system status bar. 
  149.      * 
  150.      * If the platform is running Jelly Bean or earlier, or translucent system 
  151.      * UI modes have not been enabled in either the theme or via window flags, 
  152.      * then this method does nothing. 
  153.      * 
  154.      * @param enabled True to enable tinting, false to disable it (default). 
  155.      */  
  156.     public void setStatusBarTintEnabled(boolean enabled) {  
  157.         mStatusBarTintEnabled = enabled;  
  158.         if (mStatusBarAvailable) {  
  159.             mStatusBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);  
  160.         }  
  161.     }  
  162.   
  163.   
  164.     /** 
  165.      * Enable tinting of the system navigation bar. 
  166.      * 
  167.      * If the platform does not have soft navigation keys, is running Jelly Bean 
  168.      * or earlier, or translucent system UI modes have not been enabled in either 
  169.      * the theme or via window flags, then this method does nothing. 
  170.      * 
  171.      * @param enabled True to enable tinting, false to disable it (default). 
  172.      */  
  173.     public void setNavigationBarTintEnabled(boolean enabled) {  
  174.         mNavBarTintEnabled = enabled;  
  175.         if (mNavBarAvailable) {  
  176.             mNavBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);  
  177.         }  
  178.     }  
  179.   
  180.   
  181.     /** 
  182.      * Apply the specified color tint to all system UI bars. 
  183.      * 
  184.      * @param color The color of the background tint. 
  185.      */  
  186.     public void setTintColor(int color) {  
  187.         setStatusBarTintColor(color);  
  188.         setNavigationBarTintColor(color);  
  189.     }  
  190.   
  191.   
  192.     /** 
  193.      * Apply the specified drawable or color resource to all system UI bars. 
  194.      * 
  195.      * @param res The identifier of the resource. 
  196.      */  
  197.     public void setTintResource(int res) {  
  198.         setStatusBarTintResource(res);  
  199.         setNavigationBarTintResource(res);  
  200.     }  
  201.   
  202.   
  203.     /** 
  204.      * Apply the specified drawable to all system UI bars. 
  205.      * 
  206.      * @param drawable The drawable to use as the background, or null to remove it. 
  207.      */  
  208.     public void setTintDrawable(Drawable drawable) {  
  209.         setStatusBarTintDrawable(drawable);  
  210.         setNavigationBarTintDrawable(drawable);  
  211.     }  
  212.   
  213.   
  214.     /** 
  215.      * Apply the specified alpha to all system UI bars. 
  216.      * 
  217.      * @param alpha The alpha to use 
  218.      */  
  219.     public void setTintAlpha(float alpha) {  
  220.         setStatusBarAlpha(alpha);  
  221.         setNavigationBarAlpha(alpha);  
  222.     }  
  223.   
  224.   
  225.     /** 
  226.      * Apply the specified color tint to the system status bar. 
  227.      * 
  228.      * @param color The color of the background tint. 
  229.      */  
  230.     public void setStatusBarTintColor(int color) {  
  231.         if (mStatusBarAvailable) {  
  232.             mStatusBarTintView.setBackgroundColor(color);  
  233.         }  
  234.     }  
  235.   
  236.   
  237.     /** 
  238.      * Apply the specified drawable or color resource to the system status bar. 
  239.      * 
  240.      * @param res The identifier of the resource. 
  241.      */  
  242.     public void setStatusBarTintResource(int res) {  
  243.         if (mStatusBarAvailable) {  
  244.             mStatusBarTintView.setBackgroundResource(res);  
  245.         }  
  246.     }  
  247.   
  248.   
  249.     /** 
  250.      * Apply the specified drawable to the system status bar. 
  251.      * 
  252.      * @param drawable The drawable to use as the background, or null to remove it. 
  253.      */  
  254.     @SuppressWarnings("deprecation")  
  255.     public void setStatusBarTintDrawable(Drawable drawable) {  
  256.         if (mStatusBarAvailable) {  
  257.             mStatusBarTintView.setBackgroundDrawable(drawable);  
  258.         }  
  259.     }  
  260.   
  261.   
  262.     /** 
  263.      * Apply the specified alpha to the system status bar. 
  264.      * 
  265.      * @param alpha The alpha to use 
  266.      */  
  267.     @TargetApi(11)  
  268.     public void setStatusBarAlpha(float alpha) {  
  269.         if (mStatusBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {  
  270.             mStatusBarTintView.setAlpha(alpha);  
  271.         }  
  272.     }  
  273.   
  274.   
  275.     /** 
  276.      * Apply the specified color tint to the system navigation bar. 
  277.      * 
  278.      * @param color The color of the background tint. 
  279.      */  
  280.     public void setNavigationBarTintColor(int color) {  
  281.         if (mNavBarAvailable) {  
  282.             mNavBarTintView.setBackgroundColor(color);  
  283.         }  
  284.     }  
  285.   
  286.   
  287.     /** 
  288.      * Apply the specified drawable or color resource to the system navigation bar. 
  289.      * 
  290.      * @param res The identifier of the resource. 
  291.      */  
  292.     public void setNavigationBarTintResource(int res) {  
  293.         if (mNavBarAvailable) {  
  294.             mNavBarTintView.setBackgroundResource(res);  
  295.         }  
  296.     }  
  297.   
  298.   
  299.     /** 
  300.      * Apply the specified drawable to the system navigation bar. 
  301.      * 
  302.      * @param drawable The drawable to use as the background, or null to remove it. 
  303.      */  
  304.     @SuppressWarnings("deprecation")  
  305.     public void setNavigationBarTintDrawable(Drawable drawable) {  
  306.         if (mNavBarAvailable) {  
  307.             mNavBarTintView.setBackgroundDrawable(drawable);  
  308.         }  
  309.     }  
  310.   
  311.   
  312.     /** 
  313.      * Apply the specified alpha to the system navigation bar. 
  314.      * 
  315.      * @param alpha The alpha to use 
  316.      */  
  317.     @TargetApi(11)  
  318.     public void setNavigationBarAlpha(float alpha) {  
  319.         if (mNavBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {  
  320.             mNavBarTintView.setAlpha(alpha);  
  321.         }  
  322.     }  
  323.   
  324.   
  325.     /** 
  326.      * Get the system bar configuration. 
  327.      * 
  328.      * @return The system bar configuration for the current device configuration. 
  329.      */  
  330.     public SystemBarConfig getConfig() {  
  331.         return mConfig;  
  332.     }  
  333.   
  334.   
  335.     /** 
  336.      * Is tinting enabled for the system status bar? 
  337.      * 
  338.      * @return True if enabled, False otherwise. 
  339.      */  
  340.     public boolean isStatusBarTintEnabled() {  
  341.         return mStatusBarTintEnabled;  
  342.     }  
  343.   
  344.   
  345.     /** 
  346.      * Is tinting enabled for the system navigation bar? 
  347.      * 
  348.      * @return True if enabled, False otherwise. 
  349.      */  
  350.     public boolean isNavBarTintEnabled() {  
  351.         return mNavBarTintEnabled;  
  352.     }  
  353.   
  354.   
  355.     private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {  
  356.         mStatusBarTintView = new View(context);  
  357.         LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());  
  358.         params.gravity = Gravity.TOP;  
  359.         if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {  
  360.             params.rightMargin = mConfig.getNavigationBarWidth();  
  361.         }  
  362.         mStatusBarTintView.setLayoutParams(params);  
  363.         mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);  
  364.         mStatusBarTintView.setVisibility(View.GONE);  
  365.         decorViewGroup.addView(mStatusBarTintView);  
  366.     }  
  367.   
  368.   原创作品,未经允许禁止转载,转载请注明来自:http://www.cnblogs.com/jiangbeixiaoqiao/
  369.     private void setupNavBarView(Context context, ViewGroup decorViewGroup) {  
  370.         mNavBarTintView = new View(context);  
  371.         LayoutParams params;  
  372.         if (mConfig.isNavigationAtBottom()) {  
  373.             params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getNavigationBarHeight());  
  374.             params.gravity = Gravity.BOTTOM;  
  375.         } else {  
  376.             params = new LayoutParams(mConfig.getNavigationBarWidth(), LayoutParams.MATCH_PARENT);  
  377.             params.gravity = Gravity.RIGHT;  
  378.         }  
  379.         mNavBarTintView.setLayoutParams(params);  
  380.         mNavBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);  
  381.         mNavBarTintView.setVisibility(View.GONE);  
  382.         decorViewGroup.addView(mNavBarTintView);  
  383.     }  
  384.   
  385.   
  386.     /** 
  387.      * Class which describes system bar sizing and other characteristics for the current 
  388.      * device configuration. 
  389.      * 
  390.      */  
  391.     public static class SystemBarConfig {  
  392.   
  393.   
  394.         private static final String STATUS_BAR_HEIGHT_RES_NAME = "status_bar_height";  
  395.         private static final String NAV_BAR_HEIGHT_RES_NAME = "navigation_bar_height";  
  396.         private static final String NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME = "navigation_bar_height_landscape";  
  397.         private static final String NAV_BAR_WIDTH_RES_NAME = "navigation_bar_width";  
  398.         private static final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar";  
  399.   
  400.   
  401.         private final boolean mTranslucentStatusBar;  
  402.         private final boolean mTranslucentNavBar;  
  403.         private final int mStatusBarHeight;  
  404.         private final int mActionBarHeight;  
  405.         private final boolean mHasNavigationBar;  
  406.         private final int mNavigationBarHeight;  
  407.         private final int mNavigationBarWidth;  
  408.         private final boolean mInPortrait;  
  409.         private final float mSmallestWidthDp;  
  410.   
  411.   
  412.         private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) {  
  413.             Resources res = activity.getResources();  
  414.             mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);  
  415.             mSmallestWidthDp = getSmallestWidthDp(activity);  
  416.             mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);  
  417.             mActionBarHeight = getActionBarHeight(activity);  
  418.             mNavigationBarHeight = getNavigationBarHeight(activity);  
  419.             mNavigationBarWidth = getNavigationBarWidth(activity);  
  420.             mHasNavigationBar = (mNavigationBarHeight > 0);  
  421.             mTranslucentStatusBar = translucentStatusBar;  
  422.             mTranslucentNavBar = traslucentNavBar;  
  423.         }  
  424.   
  425.   
  426.         @TargetApi(14)  
  427.         private int getActionBarHeight(Context context) {  
  428.             int result = 0;  
  429.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {  
  430.                 TypedValue tv = new TypedValue();  
  431.                 context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);  
  432.                 result = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());  
  433.             }  
  434.             return result;  
  435.         }  
  436.   
  437.   
  438.         @TargetApi(14)  
  439.         private int getNavigationBarHeight(Context context) {  
  440.             Resources res = context.getResources();  
  441.             int result = 0;  
  442.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {  
  443.                 if (hasNavBar(context)) {  
  444.                     String key;  
  445.                     if (mInPortrait) {  
  446.                         key = NAV_BAR_HEIGHT_RES_NAME;  
  447.                     } else {  
  448.                         key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME;  
  449.                     }  
  450.                     return getInternalDimensionSize(res, key);  
  451.                 }  
  452.             }  
  453.             return result;  
  454.         }  
  455.   
  456.   
  457.         @TargetApi(14)  
  458.         private int getNavigationBarWidth(Context context) {  
  459.             Resources res = context.getResources();  
  460.             int result = 0;  
  461.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {  
  462.                 if (hasNavBar(context)) {  
  463.                     return getInternalDimensionSize(res, NAV_BAR_WIDTH_RES_NAME);  
  464.                 }  
  465.             }  
  466.             return result;  
  467.         }  
  468.   
  469.   
  470.         @TargetApi(14)  
  471.         private boolean hasNavBar(Context context) {  
  472.             Resources res = context.getResources();  
  473.             int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool""android");  
  474.             if (resourceId != 0) {  
  475.                 boolean hasNav = res.getBoolean(resourceId);  
  476.                 // check override flag (see static block)  
  477.                 if ("1".equals(sNavBarOverride)) {  
  478.                     hasNav = false;  
  479.                 } else if ("0".equals(sNavBarOverride)) {  
  480.                     hasNav = true;  
  481.                 }  
  482.                 return hasNav;  
  483.             } else { // fallback  
  484.                 return !ViewConfiguration.get(context).hasPermanentMenuKey();  
  485.             }  
  486.         }  
  487.   
  488.   
  489.         private int getInternalDimensionSize(Resources res, String key) {  
  490.             int result = 0;  
  491.             int resourceId = res.getIdentifier(key, "dimen""android");  
  492.             if (resourceId > 0) {  
  493.                 result = res.getDimensionPixelSize(resourceId);  
  494.             }  
  495.             return result;  
  496.         }  
  497.   
  498.   
  499.         @SuppressLint("NewApi")  
  500.         private float getSmallestWidthDp(Activity activity) {  
  501.             DisplayMetrics metrics = new DisplayMetrics();  
  502.             if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {  
  503.                 activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);  
  504.             } else {  
  505.                 // TODO this is not correct, but we don't really care pre-kitkat  
  506.                 activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);  
  507.             }  
  508.             float widthDp = metrics.widthPixels / metrics.density;  
  509.             float heightDp = metrics.heightPixels / metrics.density;  
  510.             return Math.min(widthDp, heightDp);  
  511.         }  
  512.   
  513.   
  514.         /** 
  515.          * Should a navigation bar appear at the bottom of the screen in the current 
  516.          * device configuration? A navigation bar may appear on the right side of 
  517.          * the screen in certain configurations. 
  518.          * 
  519.          * @return True if navigation should appear at the bottom of the screen, False otherwise. 
  520.          */  
  521.         public boolean isNavigationAtBottom() {  
  522.             return (mSmallestWidthDp >= 600 || mInPortrait);  
  523.         }  
  524.   
  525.   
  526.         /** 
  527.          * Get the height of the system status bar. 
  528.          * 
  529.          * @return The height of the status bar (in pixels). 
  530.          */  
  531.         public int getStatusBarHeight() {  
  532.             return mStatusBarHeight;  
  533.         }  
  534.   
  535.   
  536.         /** 
  537.          * Get the height of the action bar. 
  538.          * 
  539.          * @return The height of the action bar (in pixels). 
  540.          */  
  541.         public int getActionBarHeight() {  
  542.             return mActionBarHeight;  
  543.         }  
  544.   
  545.   
  546.         /** 
  547.          * Does this device have a system navigation bar? 
  548.          * 
  549.          * @return True if this device uses soft key navigation, False otherwise. 
  550.          */  
  551.         public boolean hasNavigtionBar() {  
  552.             return mHasNavigationBar;  
  553.         }  
  554.   
  555.   
  556.         /** 
  557.          * Get the height of the system navigation bar. 
  558.          * 
  559.          * @return The height of the navigation bar (in pixels). If the device does not have 
  560.          * soft navigation keys, this will always return 0. 
  561.          */  
  562.         public int getNavigationBarHeight() {  
  563.             return mNavigationBarHeight;  
  564.         }  
  565.   
  566.   
  567.         /** 
  568.          * Get the width of the system navigation bar when it is placed vertically on the screen. 
  569.          * 
  570.          * @return The width of the navigation bar (in pixels). If the device does not have 
  571.          * soft navigation keys, this will always return 0. 
  572.          */  
  573.         public int getNavigationBarWidth() {  
  574.             return mNavigationBarWidth;  
  575.         }  
  576.   
  577.   
  578.         /** 
  579.          * Get the layout inset for any system UI that appears at the top of the screen. 
  580.          * 
  581.          * @param withActionBar True to include the height of the action bar, False otherwise. 
  582.          * @return The layout inset (in pixels). 
  583.          */  
  584.         public int getPixelInsetTop(boolean withActionBar) {  
  585.             return (mTranslucentStatusBar ? mStatusBarHeight : 0) + (withActionBar ? mActionBarHeight : 0);  
  586.         }  
  587.   
  588.   
  589.         /** 
  590.          * Get the layout inset for any system UI that appears at the bottom of the screen. 
  591.          * 
  592.          * @return The layout inset (in pixels). 
  593.          */  
  594.         public int getPixelInsetBottom() {  
  595.             if (mTranslucentNavBar && isNavigationAtBottom()) {  
  596.                 return mNavigationBarHeight;  
  597.             } else {  
  598.                 return 0;  
  599.             }  
  600.         }  
  601.   
  602.   
  603.         /** 
  604.          * Get the layout inset for any system UI that appears at the right of the screen. 
  605.          * 
  606.          * @return The layout inset (in pixels). 
  607.          */  
  608.         public int getPixelInsetRight() {  
  609.             if (mTranslucentNavBar && !isNavigationAtBottom()) {  
  610.                 return mNavigationBarWidth;  
  611.             } else {  
  612.                 return 0;  
  613.             }  
  614.         }  
  615.   
  616.   
  617.     }  
  618. 原创作品,未经允许禁止转载,转载请注明来自:http://www.cnblogs.com/jiangbeixiaoqiao/
  619.   
  620. }  
  621. </span>  
原文地址:https://www.cnblogs.com/jiangbeixiaoqiao/p/5846427.html