我们知道IOS上的应用,状态栏的颜色总能与应用标题栏颜色保持一致,用户体验很不错,那安卓是否可以呢?若是在安卓4.4之前,答案是否定的,但在4.4之后,谷歌允许开发者自定义状态栏背景颜色啦,这是个不错的体验!若你手机上安装有最新版的qq,并且你的安卓SDK版本是4.4及以上,你可以看下它的效果:

实现此功能有两种方法:

1.在xml中设置主题或自定义style;

[html] view
plain
copy

  1. Theme.Holo.Light.NoActionBar.TranslucentDecor
[html] view
plain
copy

  1. Theme.Holo.NoActionBar.TranslucentDecor
[html] view
plain
copy

  1. <style name="AppTheme" parent="AppBaseTheme">
  2. <!-- Status Bar -->
  3. <item name="android:windowTranslucentStatus">true</item>
  4. <!-- Navigation Bar -->
  5. <item name="android:windowTranslucentNavigation">true</item>
  6. </style>

鉴于市面上各种手机的SDK的各种版本,不建议采用这种方法;

2.在代码中控制;

可以首先创建一个BaseActivity,在onCreate方法中进行处理:

[html] view
plain
copy

  1. @Override
  2. protected void onCreate(Bundle savedInstanceState) {
  3. super.onCreate(savedInstanceState);
  4. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  5. setTranslucentStatus(true);
  6. SystemBarTintManager tintManager = new SystemBarTintManager(this);
  7. tintManager.setStatusBarTintEnabled(true);
  8. tintManager.setStatusBarTintResource(R.color.top_bg_color);//通知栏所需颜色
  9. }
  10. setContentView(R.layout.main_activity);
  11. }
  12. @TargetApi(19)
  13. private void setTranslucentStatus(boolean on) {
  14. Window win = getWindow();
  15. WindowManager.LayoutParams winParams = win.getAttributes();
  16. final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
  17. if (on) {
  18. winParams.flags |= bits;
  19. } else {
  20. winParams.flags &= ~bits;
  21. }
  22. win.setAttributes(winParams);
  23. }

需注意的是, tintManager.setStatusBarTintResource(R.color.top_bg_color);这一步的颜色值(即把你的状态栏颜色与你的标题栏颜色保持一致)要写在color.xml中去,如果用Color.praseColor则会报错。

SystemBarTintManager.java源码:

[html] view
plain
copy

  1. import android.annotation.SuppressLint;
  2. import android.annotation.TargetApi;
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.content.res.Configuration;
  6. import android.content.res.Resources;
  7. import android.content.res.TypedArray;
  8. import android.graphics.drawable.Drawable;
  9. import android.os.Build;
  10. import android.util.DisplayMetrics;
  11. import android.util.TypedValue;
  12. import android.view.Gravity;
  13. import android.view.View;
  14. import android.view.ViewConfiguration;
  15. import android.view.ViewGroup;
  16. import android.view.Window;
  17. import android.view.WindowManager;
  18. import android.widget.FrameLayout.LayoutParams;
  19. import java.lang.reflect.Method;
  20. /**
  21. * Class to manage status and navigation bar tint effects when using KitKat
  22. * translucent system UI modes.
  23. *
  24. */
  25. @SuppressWarnings({ "rawtypes", "unchecked" })
  26. public class SystemBarTintManager {
  27. static {
  28. // Android allows a system property to override the presence of the navigation bar.
  29. // Used by the emulator.
  30. // See https://github.com/android/platform_frameworks_base/blob/master/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java#L1076
  31. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  32. try {
  33. Class c = Class.forName("android.os.SystemProperties");
  34. Method m = c.getDeclaredMethod("get", String.class);
  35. m.setAccessible(true);
  36. sNavBarOverride = (String) m.invoke(null, "qemu.hw.mainkeys");
  37. } catch (Throwable e) {
  38. sNavBarOverride = null;
  39. }
  40. }
  41. }
  42. /**
  43. * The default system bar tint color value.
  44. */
  45. public static final int DEFAULT_TINT_COLOR = 0x99000000;
  46. private static String sNavBarOverride;
  47. private final SystemBarConfig mConfig;
  48. private boolean mStatusBarAvailable;
  49. private boolean mNavBarAvailable;
  50. private boolean mStatusBarTintEnabled;
  51. private boolean mNavBarTintEnabled;
  52. private View mStatusBarTintView;
  53. private View mNavBarTintView;
  54. /**
  55. * Constructor. Call this in the host activity onCreate method after its
  56. * content view has been set. You should always create new instances when
  57. * the host activity is recreated.
  58. *
  59. * @param activity The host activity.
  60. */
  61. @TargetApi(19)
  62. public SystemBarTintManager(Activity activity) {
  63. Window win = activity.getWindow();
  64. ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();
  65. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  66. // check theme attrs
  67. int[] attrs = {android.R.attr.windowTranslucentStatus,
  68. android.R.attr.windowTranslucentNavigation};
  69. TypedArray a = activity.obtainStyledAttributes(attrs);
  70. try {
  71. mStatusBarAvailable = a.getBoolean(0, false);
  72. mNavBarAvailable = a.getBoolean(1, false);
  73. } finally {
  74. a.recycle();
  75. }
  76. // check window flags
  77. WindowManager.LayoutParams winParams = win.getAttributes();
  78. int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
  79. if ((winParams.flags & bits) != 0) {
  80. mStatusBarAvailable = true;
  81. }
  82. bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
  83. if ((winParams.flags & bits) != 0) {
  84. mNavBarAvailable = true;
  85. }
  86. }
  87. mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
  88. // device might not have virtual navigation keys
  89. if (!mConfig.hasNavigtionBar()) {
  90. mNavBarAvailable = false;
  91. }
  92. if (mStatusBarAvailable) {
  93. setupStatusBarView(activity, decorViewGroup);
  94. }
  95. if (mNavBarAvailable) {
  96. setupNavBarView(activity, decorViewGroup);
  97. }
  98. }
  99. /**
  100. * Enable tinting of the system status bar.
  101. *
  102. * If the platform is running Jelly Bean or earlier, or translucent system
  103. * UI modes have not been enabled in either the theme or via window flags,
  104. * then this method does nothing.
  105. *
  106. * @param enabled True to enable tinting, false to disable it (default).
  107. */
  108. public void setStatusBarTintEnabled(boolean enabled) {
  109. mStatusBarTintEnabled = enabled;
  110. if (mStatusBarAvailable) {
  111. mStatusBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);
  112. }
  113. }
  114. /**
  115. * Enable tinting of the system navigation bar.
  116. *
  117. * If the platform does not have soft navigation keys, is running Jelly Bean
  118. * or earlier, or translucent system UI modes have not been enabled in either
  119. * the theme or via window flags, then this method does nothing.
  120. *
  121. * @param enabled True to enable tinting, false to disable it (default).
  122. */
  123. public void setNavigationBarTintEnabled(boolean enabled) {
  124. mNavBarTintEnabled = enabled;
  125. if (mNavBarAvailable) {
  126. mNavBarTintView.setVisibility(enabled ? View.VISIBLE : View.GONE);
  127. }
  128. }
  129. /**
  130. * Apply the specified color tint to all system UI bars.
  131. *
  132. * @param color The color of the background tint.
  133. */
  134. public void setTintColor(int color) {
  135. setStatusBarTintColor(color);
  136. setNavigationBarTintColor(color);
  137. }
  138. /**
  139. * Apply the specified drawable or color resource to all system UI bars.
  140. *
  141. * @param res The identifier of the resource.
  142. */
  143. public void setTintResource(int res) {
  144. setStatusBarTintResource(res);
  145. setNavigationBarTintResource(res);
  146. }
  147. /**
  148. * Apply the specified drawable to all system UI bars.
  149. *
  150. * @param drawable The drawable to use as the background, or null to remove it.
  151. */
  152. public void setTintDrawable(Drawable drawable) {
  153. setStatusBarTintDrawable(drawable);
  154. setNavigationBarTintDrawable(drawable);
  155. }
  156. /**
  157. * Apply the specified alpha to all system UI bars.
  158. *
  159. * @param alpha The alpha to use
  160. */
  161. public void setTintAlpha(float alpha) {
  162. setStatusBarAlpha(alpha);
  163. setNavigationBarAlpha(alpha);
  164. }
  165. /**
  166. * Apply the specified color tint to the system status bar.
  167. *
  168. * @param color The color of the background tint.
  169. */
  170. public void setStatusBarTintColor(int color) {
  171. if (mStatusBarAvailable) {
  172. mStatusBarTintView.setBackgroundColor(color);
  173. }
  174. }
  175. /**
  176. * Apply the specified drawable or color resource to the system status bar.
  177. *
  178. * @param res The identifier of the resource.
  179. */
  180. public void setStatusBarTintResource(int res) {
  181. if (mStatusBarAvailable) {
  182. mStatusBarTintView.setBackgroundResource(res);
  183. }
  184. }
  185. /**
  186. * Apply the specified drawable to the system status bar.
  187. *
  188. * @param drawable The drawable to use as the background, or null to remove it.
  189. */
  190. @SuppressWarnings("deprecation")
  191. public void setStatusBarTintDrawable(Drawable drawable) {
  192. if (mStatusBarAvailable) {
  193. mStatusBarTintView.setBackgroundDrawable(drawable);
  194. }
  195. }
  196. /**
  197. * Apply the specified alpha to the system status bar.
  198. *
  199. * @param alpha The alpha to use
  200. */
  201. @TargetApi(11)
  202. public void setStatusBarAlpha(float alpha) {
  203. if (mStatusBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
  204. mStatusBarTintView.setAlpha(alpha);
  205. }
  206. }
  207. /**
  208. * Apply the specified color tint to the system navigation bar.
  209. *
  210. * @param color The color of the background tint.
  211. */
  212. public void setNavigationBarTintColor(int color) {
  213. if (mNavBarAvailable) {
  214. mNavBarTintView.setBackgroundColor(color);
  215. }
  216. }
  217. /**
  218. * Apply the specified drawable or color resource to the system navigation bar.
  219. *
  220. * @param res The identifier of the resource.
  221. */
  222. public void setNavigationBarTintResource(int res) {
  223. if (mNavBarAvailable) {
  224. mNavBarTintView.setBackgroundResource(res);
  225. }
  226. }
  227. /**
  228. * Apply the specified drawable to the system navigation bar.
  229. *
  230. * @param drawable The drawable to use as the background, or null to remove it.
  231. */
  232. @SuppressWarnings("deprecation")
  233. public void setNavigationBarTintDrawable(Drawable drawable) {
  234. if (mNavBarAvailable) {
  235. mNavBarTintView.setBackgroundDrawable(drawable);
  236. }
  237. }
  238. /**
  239. * Apply the specified alpha to the system navigation bar.
  240. *
  241. * @param alpha The alpha to use
  242. */
  243. @TargetApi(11)
  244. public void setNavigationBarAlpha(float alpha) {
  245. if (mNavBarAvailable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
  246. mNavBarTintView.setAlpha(alpha);
  247. }
  248. }
  249. /**
  250. * Get the system bar configuration.
  251. *
  252. * @return The system bar configuration for the current device configuration.
  253. */
  254. public SystemBarConfig getConfig() {
  255. return mConfig;
  256. }
  257. /**
  258. * Is tinting enabled for the system status bar?
  259. *
  260. * @return True if enabled, False otherwise.
  261. */
  262. public boolean isStatusBarTintEnabled() {
  263. return mStatusBarTintEnabled;
  264. }
  265. /**
  266. * Is tinting enabled for the system navigation bar?
  267. *
  268. * @return True if enabled, False otherwise.
  269. */
  270. public boolean isNavBarTintEnabled() {
  271. return mNavBarTintEnabled;
  272. }
  273. private void setupStatusBarView(Context context, ViewGroup decorViewGroup) {
  274. mStatusBarTintView = new View(context);
  275. LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
  276. params.gravity = Gravity.TOP;
  277. if (mNavBarAvailable && !mConfig.isNavigationAtBottom()) {
  278. params.rightMargin = mConfig.getNavigationBarWidth();
  279. }
  280. mStatusBarTintView.setLayoutParams(params);
  281. mStatusBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
  282. mStatusBarTintView.setVisibility(View.GONE);
  283. decorViewGroup.addView(mStatusBarTintView);
  284. }
  285. private void setupNavBarView(Context context, ViewGroup decorViewGroup) {
  286. mNavBarTintView = new View(context);
  287. LayoutParams params;
  288. if (mConfig.isNavigationAtBottom()) {
  289. params = new LayoutParams(LayoutParams.MATCH_PARENT, mConfig.getNavigationBarHeight());
  290. params.gravity = Gravity.BOTTOM;
  291. } else {
  292. params = new LayoutParams(mConfig.getNavigationBarWidth(), LayoutParams.MATCH_PARENT);
  293. params.gravity = Gravity.RIGHT;
  294. }
  295. mNavBarTintView.setLayoutParams(params);
  296. mNavBarTintView.setBackgroundColor(DEFAULT_TINT_COLOR);
  297. mNavBarTintView.setVisibility(View.GONE);
  298. decorViewGroup.addView(mNavBarTintView);
  299. }
  300. /**
  301. * Class which describes system bar sizing and other characteristics for the current
  302. * device configuration.
  303. *
  304. */
  305. public static class SystemBarConfig {
  306. private static final String STATUS_BAR_HEIGHT_RES_NAME = "status_bar_height";
  307. private static final String NAV_BAR_HEIGHT_RES_NAME = "navigation_bar_height";
  308. private static final String NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME = "navigation_bar_height_landscape";
  309. private static final String NAV_BAR_WIDTH_RES_NAME = "navigation_bar_width";
  310. private static final String SHOW_NAV_BAR_RES_NAME = "config_showNavigationBar";
  311. private final boolean mTranslucentStatusBar;
  312. private final boolean mTranslucentNavBar;
  313. private final int mStatusBarHeight;
  314. private final int mActionBarHeight;
  315. private final boolean mHasNavigationBar;
  316. private final int mNavigationBarHeight;
  317. private final int mNavigationBarWidth;
  318. private final boolean mInPortrait;
  319. private final float mSmallestWidthDp;
  320. private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) {
  321. Resources res = activity.getResources();
  322. mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
  323. mSmallestWidthDp = getSmallestWidthDp(activity);
  324. mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
  325. mActionBarHeight = getActionBarHeight(activity);
  326. mNavigationBarHeight = getNavigationBarHeight(activity);
  327. mNavigationBarWidth = getNavigationBarWidth(activity);
  328. mHasNavigationBar = (mNavigationBarHeight > 0);
  329. mTranslucentStatusBar = translucentStatusBar;
  330. mTranslucentNavBar = traslucentNavBar;
  331. }
  332. @TargetApi(14)
  333. private int getActionBarHeight(Context context) {
  334. int result = 0;
  335. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
  336. TypedValue tv = new TypedValue();
  337. context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);
  338. result = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
  339. }
  340. return result;
  341. }
  342. @TargetApi(14)
  343. private int getNavigationBarHeight(Context context) {
  344. Resources res = context.getResources();
  345. int result = 0;
  346. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
  347. if (hasNavBar(context)) {
  348. String key;
  349. if (mInPortrait) {
  350. key = NAV_BAR_HEIGHT_RES_NAME;
  351. } else {
  352. key = NAV_BAR_HEIGHT_LANDSCAPE_RES_NAME;
  353. }
  354. return getInternalDimensionSize(res, key);
  355. }
  356. }
  357. return result;
  358. }
  359. @TargetApi(14)
  360. private int getNavigationBarWidth(Context context) {
  361. Resources res = context.getResources();
  362. int result = 0;
  363. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
  364. if (hasNavBar(context)) {
  365. return getInternalDimensionSize(res, NAV_BAR_WIDTH_RES_NAME);
  366. }
  367. }
  368. return result;
  369. }
  370. @TargetApi(14)
  371. private boolean hasNavBar(Context context) {
  372. Resources res = context.getResources();
  373. int resourceId = res.getIdentifier(SHOW_NAV_BAR_RES_NAME, "bool", "android");
  374. if (resourceId != 0) {
  375. boolean hasNav = res.getBoolean(resourceId);
  376. // check override flag (see static block)
  377. if ("1".equals(sNavBarOverride)) {
  378. hasNav = false;
  379. } else if ("0".equals(sNavBarOverride)) {
  380. hasNav = true;
  381. }
  382. return hasNav;
  383. } else { // fallback
  384. return !ViewConfiguration.get(context).hasPermanentMenuKey();
  385. }
  386. }
  387. private int getInternalDimensionSize(Resources res, String key) {
  388. int result = 0;
  389. int resourceId = res.getIdentifier(key, "dimen", "android");
  390. if (resourceId > 0) {
  391. result = res.getDimensionPixelSize(resourceId);
  392. }
  393. return result;
  394. }
  395. @SuppressLint("NewApi")
  396. private float getSmallestWidthDp(Activity activity) {
  397. DisplayMetrics metrics = new DisplayMetrics();
  398. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
  399. activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
  400. } else {
  401. // TODO this is not correct, but we don't really care pre-kitkat
  402. activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
  403. }
  404. float widthDp = metrics.widthPixels / metrics.density;
  405. float heightDp = metrics.heightPixels / metrics.density;
  406. return Math.min(widthDp, heightDp);
  407. }
  408. /**
  409. * Should a navigation bar appear at the bottom of the screen in the current
  410. * device configuration? A navigation bar may appear on the right side of
  411. * the screen in certain configurations.
  412. *
  413. * @return True if navigation should appear at the bottom of the screen, False otherwise.
  414. */
  415. public boolean isNavigationAtBottom() {
  416. return (mSmallestWidthDp >= 600 || mInPortrait);
  417. }
  418. /**
  419. * Get the height of the system status bar.
  420. *
  421. * @return The height of the status bar (in pixels).
  422. */
  423. public int getStatusBarHeight() {
  424. return mStatusBarHeight;
  425. }
  426. /**
  427. * Get the height of the action bar.
  428. *
  429. * @return The height of the action bar (in pixels).
  430. */
  431. public int getActionBarHeight() {
  432. return mActionBarHeight;
  433. }
  434. /**
  435. * Does this device have a system navigation bar?
  436. *
  437. * @return True if this device uses soft key navigation, False otherwise.
  438. */
  439. public boolean hasNavigtionBar() {
  440. return mHasNavigationBar;
  441. }
  442. /**
  443. * Get the height of the system navigation bar.
  444. *
  445. * @return The height of the navigation bar (in pixels). If the device does not have
  446. * soft navigation keys, this will always return 0.
  447. */
  448. public int getNavigationBarHeight() {
  449. return mNavigationBarHeight;
  450. }
  451. /**
  452. * Get the width of the system navigation bar when it is placed vertically on the screen.
  453. *
  454. * @return The width of the navigation bar (in pixels). If the device does not have
  455. * soft navigation keys, this will always return 0.
  456. */
  457. public int getNavigationBarWidth() {
  458. return mNavigationBarWidth;
  459. }
  460. /**
  461. * Get the layout inset for any system UI that appears at the top of the screen.
  462. *
  463. * @param withActionBar True to include the height of the action bar, False otherwise.
  464. * @return The layout inset (in pixels).
  465. */
  466. public int getPixelInsetTop(boolean withActionBar) {
  467. return (mTranslucentStatusBar ? mStatusBarHeight : 0) + (withActionBar ? mActionBarHeight : 0);
  468. }
  469. /**
  470. * Get the layout inset for any system UI that appears at the bottom of the screen.
  471. *
  472. * @return The layout inset (in pixels).
  473. */
  474. public int getPixelInsetBottom() {
  475. if (mTranslucentNavBar && isNavigationAtBottom()) {
  476. return mNavigationBarHeight;
  477. } else {
  478. return 0;
  479. }
  480. }
  481. /**
  482. * Get the layout inset for any system UI that appears at the right of the screen.
  483. *
  484. * @return The layout inset (in pixels).
  485. */
  486. public int getPixelInsetRight() {
  487. if (mTranslucentNavBar && !isNavigationAtBottom()) {
  488. return mNavigationBarWidth;
  489. } else {
  490. return 0;
  491. }
  492. }
  493. }
  494. }

引用自:https://github.com/jgilfelt/SystemBarTint

代码复制进你的项目即可,好了,这些工作完成之后我们来看下效果:

貌似已经达到效果了,但仔细观察,好像标题栏被提上去了,就是说APP界面全屏了,状态了盖在了APP上,恩,这并非我们想要的效果,那如何将界面从状态栏下部开始呢,只需要在Activity的布局文件最外层控件加上一个属性:

android:fitsSystemWindows="true"就可以啦!看下效果:

OK,大功告成!

PS:在使用过程中发现了一些问题,使用以上方法对单个Activity有效,但是对继承了TabActivity的导航页怎么办呢?假如MainActivity继承了TabActivity,Tab1Activity、Tab2Activity、Tab3Activity是三个子项,那么设置状态栏的代码需写在MainActivity中,而 android:fitsSystemWindows="true"需写在三个子Activity的xml布局文件中,这样设置后仍然有问题,就是进入应用后首页也就是Tab1Activity没有问题,而Tab2Activity、Tab3Activity却没达到效果,它们的效果相当于未加android:fitsSystemWindows="true"时的效果,期初我怀疑是Activity不同的原因,因此我把Tab1Activity和Tab3Activity调了下位置,结果Tab3Activity成为首页后正常,而Tab1Activity又不正常了,百思不得姐,最后实在没办法,就在Tab2Activity、Tab3Activity的OnCreate方法中加了几句代码:

[html] view
plain
copy

  1. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
  2. ((LinearLayout)findViewById(R.id.ll)).setPadding(0, SysUtils.getStatusHeight(this), 0,0);
  3. }

意思是,先求出状态栏高度,然后设置最外层控件的PaddingTop值为状态栏高度,结果正好达到效果,至于为什么只有首页Activity可以达到效果,而后面的子项无法达到效果,本人也在郁闷中,有知道的朋友可以分享下!

状态栏高度算法:

[html] view
plain
copy

  1. /**
  2. * 状态栏高度算法
  3. * @param activity
  4. * @return
  5. */
  6. public static int getStatusHeight(Activity activity){
  7. int statusHeight = 0;
  8. Rect localRect = new Rect();
  9. activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
  10. statusHeight = localRect.top;
  11. if (0 == statusHeight){
  12. Class<?> localClass;
  13. try {
  14. localClass = Class.forName("com.android.internal.R$dimen");
  15. Object localObject = localClass.newInstance();
  16. int i5 = Integer.parseInt(localClass.getField("status_bar_height").get(localObject).toString());
  17. statusHeight = activity.getResources().getDimensionPixelSize(i5);
  18. } catch (ClassNotFoundException e) {
  19. e.printStackTrace();
  20. } catch (IllegalAccessException e) {
  21. e.printStackTrace();
  22. } catch (InstantiationException e) {
  23. e.printStackTrace();
  24. } catch (NumberFormatException e) {
  25. e.printStackTrace();
  26. } catch (IllegalArgumentException e) {
  27. e.printStackTrace();
  28. } catch (SecurityException e) {
  29. e.printStackTrace();
  30. } catch (NoSuchFieldException e) {
  31. e.printStackTrace();
  32. }
  33. }
  34. return statusHeight;
  35. }

最新文章

  1. MySQL学习笔记六:基本DML操作
  2. awk 高级技巧
  3. CentOS下解压缩命令
  4. Windows Store 开发总结——文件操作
  5. Unity3D 通用提示窗口实现分析(Inventory Pro学习总结)
  6. 从零开始,让你的框架支持CocoaPods
  7. yum 安装 PHP,apache,nginx,mysql
  8. DButils工具类能够用来获取数据库连接向数据库插入更新删除对象2
  9. IIS服务器 远程发布(Web Deploy)配置 VS2010 开发环境 Windows Server 2008服务器系统
  10. MFC 控件用法
  11. dplyr 数据操作 数据过滤 (filter)
  12. Lucene + Hadoop 分布式搜索运行框架 Nut 1.0a9转自http://www.linuxidc.com/Linux/2012-02/53113.htm
  13. log4jdbc打印完整SQL
  14. js 前端操作的分页路由设计
  15. activiti 动态配置 activiti 监听引擎启动和初始化(高级源码篇)
  16. 剑指Offer 36. 两个链表的第一个公共结点 (链表)
  17. dbeaver can&#39;t connect HBase1.2 using phoenix driver #1863
  18. ASP.NET MVC多语言 仿微软网站效果(转)
  19. intellij idea建立maven项目
  20. Struts2+JSON数据

热门文章

  1. Android属性动画完全解析(中),ValueAnimator和ObjectAnimator的高级用法
  2. ListView下拉刷新上拉加载更多实现
  3. Dynamics CRM2013 从subgrid中打开快速创建窗体创建数据
  4. java创建对象详解和多态问题
  5. 如何使用分布是缓存Hazelcast
  6. 【Android应用开发】分享一个录制 Android 屏幕 gif 格式的小技巧
  7. SSH深度历险(五) 深入浅出-----IOC AND AOP
  8. EBS开发技术之Patch安装
  9. JQuery实战---初识JQuery+入门实例
  10. 【Unity Shaders】Shader学习资源和Surface Shader概述