实现步骤:
1、下载第三方开源库https://github.com/jgilfelt/SystemBarTint(注意事项,V19以上才会出现透明
2、项目目录res下新建values-v19文件夹,添加style.xml文件,内容如下

<resources><!--Baseapplicationtheme.--><stylename="AppTheme"parent="android:Theme.Holo.Light.NoActionBar.TranslucentDecor"><!--Customizeyourthemehere.--></style></resources>

3、Activity中设置状态栏透明

<RelativeLayoutxmlns:android="xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:fitsSystemWindows="true"android:clipToPadding="true">

就是添加

android:fitsSystemWindows="true"android:clipToPadding="true"


如果还想改变状态栏的背景色,在oncreate里

@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);SystemBarTintManagertintManager=newSystemBarTintManager(this);tintManager.setStatusBarTintEnabled(true);//tintManager.setNavigationBarTintEnabled(true);tintManager.setStatusBarTintColor(Color.RED);//或者 tintManager.setTintColor(Color.parseColor("#ff0000"));}


更多相关文章

  1. Cocos2d-x + Android(安卓)+ Eclipse + Windows 8
  2. Android中JNI程序的编写(zhuan)
  3. Ubuntu 17.10 Android(安卓)studio 3.1 下的AVD配置
  4. 【android】Android(安卓)7.0适配步骤
  5. Android:不同drawable文件夹的区别
  6. 【Android】删除已知路径的文件或文件夹
  7. android studio 配置ffmpeg
  8. android studio 2.0 引导页示例
  9. Android游戏引擎AndEngine使用注意事项

随机推荐

  1. Android中使用SQlite进行数据操作
  2. 四极管:Android(安卓)rameworks/base/libs
  3. 开发android,我们需要哪些技能基础
  4. Android 专栏整理
  5. Android. Handling some SQLite issues.
  6. BootChart在Android中使用
  7. [Android]为Spinner填充数据后设置默认值
  8. android 离线语言识别
  9. Android中间键开发
  10. Android手势识别ViewFlipper触摸动画