状态栏透明
16lz
2021-01-24
实现步骤:
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"));}
更多相关文章
- Cocos2d-x + Android(安卓)+ Eclipse + Windows 8
- Android中JNI程序的编写(zhuan)
- Ubuntu 17.10 Android(安卓)studio 3.1 下的AVD配置
- 【android】Android(安卓)7.0适配步骤
- Android:不同drawable文件夹的区别
- 【Android】删除已知路径的文件或文件夹
- android studio 配置ffmpeg
- android studio 2.0 引导页示例
- Android游戏引擎AndEngine使用注意事项