如何实现Android透明ios导航栏透明

||||||||||||||||||
查看: 803|回复: 10
在线时间166 小时经验值332 最后登录注册时间帖子阅读权限50UID8023978
大学专科, 积分 332, 距离下一级还需 68 积分
该用户从未签到
G币65 最后登录注册时间
RT& &在哪里设置?怎么设置??&&给个S3 的主题& &3Q!!!
在线时间166 小时经验值332 最后登录注册时间帖子阅读权限50UID8023978
大学专科, 积分 332, 距离下一级还需 68 积分
该用户从未签到
G币65 最后登录注册时间
自己顶个!!
在线时间59 小时经验值307 最后登录注册时间帖子阅读权限50UID
大学专科, 积分 307, 距离下一级还需 93 积分
该用户从未签到
G币186 最后登录注册时间
主题不能把导航栏改成透明,要刷机
在线时间246 小时经验值2268 最后登录注册时间帖子阅读权限90UID8976713
硕士, 积分 2268, 距离下一级还需 232 积分
TA的每日心情衰 11:09签到天数: 25 天[LV.4]偶尔看看III
G币1498 最后登录注册时间
在线时间0 小时经验值15 最后登录注册时间帖子阅读权限20UID
小学生, 积分 15, 距离下一级还需 35 积分
该用户从未签到
G币0 最后登录注册时间
透明导航栏 状态栏
在线时间112 小时经验值292 最后登录注册时间帖子阅读权限50UID8432325
大学专科, 积分 292, 距离下一级还需 108 积分
该用户从未签到
G币369 最后登录注册时间
同问,顶起
在线时间31 小时经验值145 最后登录注册时间帖子阅读权限40UID1813005
高中生, 积分 145, 距离下一级还需 55 积分
TA的每日心情开心 20:06签到天数: 1 天[LV.1]初来乍到
G币168 最后登录注册时间
。。。。。。。。。。。。。。。。。。。。。
在线时间45 小时经验值223 最后登录注册时间帖子阅读权限50UID
大学专科, 积分 223, 距离下一级还需 177 积分
该用户从未签到
G币129 最后登录注册时间
据我自己所知& &现在还只能靠刷第三方ROM实现透明
在线时间20 小时经验值10498 最后登录注册时间帖子阅读权限150UID
院系主任, 积分 10498, 距离下一级还需 1702 积分
TA的每日心情无聊 23:07签到天数: 213 天[LV.7]常住居民III
G币2576 最后登录注册时间
看贴必回~~~~~~~~~~~~~~
给我一滴水,还你一杯茶。-_-||
八卦公用马甲 该用户已被删除
提示: 作者被禁止或删除 内容自动屏蔽,只有管理员或有管理权限的成员可见
看了,感觉不错,谢谢您提供
浏览过的版块
Powered by当前位置: >
android状态栏和沉浸式导航栏管理源码
时间: 22:50 来源:互联网 作者:源码搜藏 浏览:
源码类别:菜单Menu
源码大小:未知
编码格式:gbk
授权方式:免费源码
运行环境:Android studio
官方网址:暂无
欢迎加入QQ群讨论学习
android状态栏和沉浸式导航栏管理源码
android studio
compile 'com.gyf.barlibrary:barlibrary:2.2.9'
barlibrary-2.2.9.jar
基础用法(已经可以满足日常沉浸式)
ImmersionBar.with(this).init();
高级用法(每个参数的意义)
ImmersionBar.with(this)
.transparentStatusBar()
.transparentNavigationBar()
.transparentBar()
.statusBarColor(R.color.colorPrimary)
.navigationBarColor(R.color.colorPrimary)
.barColor(R.color.colorPrimary)
.statusBarAlpha(0.3f)
.navigationBarAlpha(0.4f)
.barAlpha(0.3f)
.statusBarDarkFont(true)
.flymeOSStatusBarFontColor(R.color.btn3)
.fullScreen(true)
.hideBar(BarHide.FLAG_HIDE_BAR)
.addViewSupportTransformColor(toolbar)
.titleBar(view)
.titleBarMarginTop(view)
.statusBarView(view)
.fitsSystemWindows(true)
.supportActionBar(true)
.statusBarColorTransform(R.color.orange)
.navigationBarColorTransform(R.color.orange)
.barColorTransform(R.color.orange)
.removeSupportView(toolbar)
.removeSupportAllView()
.navigationBarEnable(true)
.navigationBarWithKitkatEnable(true)
.fixMarginAtBottom(true)
.addTag(&tag&)
.getTag(&tag&)
.keyboardEnable(true)
.keyboardMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
.setOnKeyboardListener(new OnKeyboardListener() {
public void onKeyboardChange(boolean isPopup, int keyboardHeight) {
LogUtils.e(isPopup);
在activity的onDestroy方法中执行
ImmersionBar.with(this).destroy(); //必须调用该方法,防止内存泄漏
建议在BaseActivity中初始化和销毁,可以参看demo中BaseActivity
public class BaseActivity extends AppCompatActivity {
private ImmersionBar mImmersionB
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mImmersionBar = ImmersionBar.with(this);
mImmersionBar.init();
protected void onDestroy() {
super.onDestroy();
if (mImmersionBar != null)
mImmersionBar.destroy();
在Fragment中实现沉浸式
注意:2.2.6版本已将ImmersionFragment这个类标记为过时,请用户自行使用懒加载方式实现
在Fragment使用ImmersionBar
第一种,当结合viewpager使用的时候,请使用懒加载的形式,参考demo中的BaseLazyFragment这个类
第二种,当使用show()和hide()来控制Fragment显示隐藏的时候,参考demo中的BaseTwoFragment这个类
2.2.7版本以后别忘了在Fragment的onDestroy方法里销毁沉浸式了,2.2.7版本之前不需要调用
protected void onDestroy() {
super.onDestroy();
if (mImmersionBar != null)
mImmersionBar.destroy();
以show()和hide()方式控制Fragment显示隐藏,别忘了重写onHiddenChanged方法,如下
public void onHiddenChanged(boolean hidden) {
super.onHiddenChanged(hidden);
if (!hidden && mImmersionBar != null)
mImmersionBar.init();
在Activity使用ImmersionBar
第一种,当结合viewpager使用的时候,请使用viewpager的addOnPageChangeListener的方法监听沉浸式,参考demo中FragmentThreeActivity这个类
第二种,当使用show()和hide()来控制Fragment显示隐藏的时候,请在tab切换的时候使用ImmersionBar,参考demo中FragmentFourActivity这个类
使用Fragment第三方框架Fragmentation实现沉浸式
参考demo中FragmentFiveActivity和BaseFiveFragment这个类
在Dialog中实现沉浸式,具体实现参考demo
①结合dialogFragment使用,可以参考demo中的BaseDialogFragment这个类
ImmersionBar.with(this, dialog) .init();
②其他dialog
ImmersionBar.with(this, dialog, &flag&)
注意:在dialog使用,当销毁dialog同时,别忘了调用ImmersionBar的destroy方法了
状态栏与布局顶部重叠解决方案,六种方案任选其一
① 使用dimen自定义状态栏高度,不建议使用,因为设备状态栏高度并不是固定的
在values-v19/dimens.xml文件下
name=&status_bar_height&&25dp&
在values/dimens.xml文件下
name=&status_bar_height&&0dp&
然后在布局界面添加view标签,高度指定为status_bar_height
&LinearLayout xmlns:android=&/apk/res/android&
xmlns:app=&/apk/res-auto&
android:layout_width=&match_parent&
android:layout_height=&match_parent&
android:background=&@color/darker_gray&
android:orientation=&vertical&&
android:layout_width=&match_parent&
android:layout_height=&@dimen/status_bar_height&
android:background=&@color/colorPrimary& /&
&android.support.v7.widget.Toolbar
android:layout_width=&match_parent&
android:layout_height=&wrap_content&
android:background=&@color/colorPrimary&
app:title=&方法一&
app:titleTextColor=&@android:color/white& /&
&/LinearLayout&
② 使用系统的fitsSystemWindows属性,使用该属性不会导致输入框与软键盘冲突问题,不要再Fragment使用该属性
xmlns:android=&/apk/res/android&
android:layout_width=&match_parent&
android:layout_height=&match_parent&
android:orientation=&vertical&
android:fitsSystemWindows=&true&&
然后使用ImmersionBar时候必须指定状态栏颜色
ImmersionBar.with(this)
.statusBarColor(R.color.colorPrimary)
③ 使用ImmersionBar的fitsSystemWindows(boolean fits)方法
ImmersionBar.with(this)
.fitsSystemWindows(true)
.statusBarColor(R.color.colorPrimary)
④ 使用ImmersionBar的statusBarView(View view)方法
在标题栏的上方增加View标签,高度指定为0dp
xmlns:android=&/apk/res/android&
xmlns:app=&/apk/res-auto&
android:layout_width=&match_parent&
android:layout_height=&match_parent&
android:background=&@color/darker_gray&
android:orientation=&vertical&&
android:layout_width=&match_parent&
android:layout_height=&0dp&
android:background=&@color/colorPrimary& /&
android:layout_width=&match_parent&
android:layout_height=&wrap_content&
android:background=&@color/colorPrimary&
app:title=&方法四&
app:titleTextColor=&@android:color/white& /&
然后使用ImmersionBar的statusBarView方法,指定view就可以啦
ImmersionBar.with(this)
.statusBarView(view)
⑤ 使用ImmersionBar的titleBar(View view)方法,原理是设置paddingTop
ImmersionBar.with(this)
.titleBar(view)
⑥ 使用ImmersionBar的titleBarMarginTop(View view)方法,原理是设置marginTop
ImmersionBar.with(this)
.titleBarMarginTop(view)
.statusBarColor(R.color.colorPrimary)
解决EditText和软键盘的问题
第一种方案
ImmersionBar.with(this)
.keyboardEnable(true)
第二种方案 不使用keyboardEnable方法,只需要在布局的根节点(最外层节点)加上android:fitsSystemWindows=&true&属性即可,只适合纯色状态栏
当白色背景状态栏遇到不能改变状态栏字体为深色的设备时,解决方案
ImmersionBar.with(this)
.statusBarDarkFont(true, 0.2f)
状态栏和导航栏其它方法
public static boolean hasNavigationBar(Activity activity)
判断是否存在导航栏
<p style="word-wrap: break- margin: 0px 0px 16 padding: 0 box-sizing: border- color: rgb(51, 51, 51); font-family: -apple-system, BlinkMacSystemFont, &Segoe UI&, Roboto, Helvetica, Arial, sans-serif, &Apple C
转载请注明出处
源码搜藏网所有源码来自用户上传分享,版权问题及牵扯到商业纠纷均与源码搜藏网无关2014年6月 移动开发大版内专家分月排行榜第二
2015年8月 移动开发大版内专家分月排行榜第三2014年9月 移动开发大版内专家分月排行榜第三2014年7月 移动开发大版内专家分月排行榜第三
2014年6月 移动开发大版内专家分月排行榜第二
2015年8月 移动开发大版内专家分月排行榜第三2014年9月 移动开发大版内专家分月排行榜第三2014年7月 移动开发大版内专家分月排行榜第三
2014年6月 移动开发大版内专家分月排行榜第一2014年3月 移动开发大版内专家分月排行榜第一
2014年11月 移动开发大版内专家分月排行榜第二2014年4月 移动开发大版内专家分月排行榜第二2014年2月 移动开发大版内专家分月排行榜第二
本帖子已过去太久远了,不再提供回复功能。详解Android通知栏沉浸式/透明化完整解决方案
作者:tnnowu
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了详解Android通知栏沉浸式/透明化完整解决方案,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Google在Android 4.4版本加入了半透明的界面样式,在Android 5.0的时候推出了Material Design的概念。
这些样式的加入使得原本死板、丑陋、和App颜色不一致的通知栏变得更亲和、顺眼、用户体验更友好。
作者是常年做对日项目的,对日项目以界面简洁功能强大而著称。最近客户要求UI方面做一些改变,让App看上去给用户感觉更友好。所以就提到了Android 4.4以后的通知栏问题。
网上关于通知栏的文章铺天盖地,什么沉浸式,什么半透明。。。挺会拽词。也不乏有Android大神也写过类似的文章,但是那文章能看?长篇大论,程序员够累了,哪有那些时间看你在那里车轱辘话满天飞,说了一大顿表达不明白,浪费时间,写的一堆垃圾文章。
本篇文章杜绝冗余,做到最简单,最实用,对日项目比的不是代码量,而是最少的代码写出最漂亮的程序。
先上Gif图,Android 4.4 和 Android 6.0 实现样式效果之后的对比图
&Android 4.4&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Android 6.0
实现样式效果我们有两种方案
①DrawerLayout+Toolbar
②ActionBar
下面我们就来一一实现
①DrawerLayout+Toolbar
添加依赖库(谷歌提供)
compile 'com.android.support:design:25.3.1'
布局代码1:使用 DrawerLayout做最外层,引入NavigationView侧边抽屉控件
&&#63;xml version="1.0" encoding="utf-8"&#63;&
&android.support.v4.widget.DrawerLayout xmlns:android="/apk/res/android"
xmlns:app="/apk/res-auto"
xmlns:tools="/tools"
android:id="@+id/id_drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.tnnowu.android.demo.MainActivity"&
&include layout="@layout/content_layout" /&
&android.support.design.widget.NavigationView
android:id="@+id/id_navigationview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
app:itemTextColor="@color/c_light_gray3" /&
&/android.support.v4.widget.DrawerLayout&
布局代码2:里层嵌套Toolbar
&&#63;xml version="1.0" encoding="utf-8"&#63;&
&LinearLayout xmlns:android="/apk/res/android"
xmlns:app="/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"&
&android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#30469b"
android:paddingTop="@dimen/toolbar_padding_top"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="ToolBar版"
android:textSize="20sp" /&
&/android.support.v7.widget.Toolbar&
&!--内容显示布局--&
&RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"&
android:id="@+id/goToActionBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="切换到ActionBar版" /&
&/RelativeLayout&
&/LinearLayout&
Style样式:无ActionBar
&style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar"&
&!-- Customize your theme here. --&
&item name="colorPrimary"&@color/colorPrimary&/item&
&item name="colorPrimaryDark"&@color/colorPrimaryDark&/item&
&item name="colorAccent"&@color/colorAccent&/item&
主程序代码:除了要在onCreate()里面初始化 DrawerLayout、NavigationView、Toolbar控件 即initViews(),还要在onCreate()里面添加手机系统版本判断和相应的样式适配initImmersive()
private void initViews() {
mDrawerLayout = (DrawerLayout) findViewById(R.id.id_drawerlayout);
mNagigationView = (NavigationView) findViewById(R.id.id_navigationview);
mNagigationView.inflateHeaderView(R.layout.header_nav);
mNagigationView.inflateMenu(R.menu.menu_nav);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mBtn = (Button) findViewById(R.id.goToActionBar);
mToolbar.setTitle("");
if (mToolbar != null) {
setSupportActionBar(mToolbar);
ActionBarDrawerToggle mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.open, R.string.close);
mActionBarDrawerToggle.syncState();
mDrawerLayout.setDrawerListener(mActionBarDrawerToggle);
mBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, DemoActionBarActivity.class));
private void initImmersive() {
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.KITKAT) {
WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
if (Build.VERSION.SDK_INT & Build.VERSION_CODES.LOLLIPOP) {
//将侧边栏顶部延伸至status bar
mDrawerLayout.setFitsSystemWindows(true);
//将主页面顶部延伸至虽默认为false,但经测试,DrawerLayout需显示设置
mDrawerLayout.setClipToPadding(false);
这样Drawlayout + Toolbar就实现了样式改变。
&②ActionBar
&&#63;xml version="1.0" encoding="utf-8"&#63;&
&LinearLayout xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary"
android:fitsSystemWindows="true"
android:orientation="vertical"&
&!--内容显示布局--&
&RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/c_light_white"&
android:id="@+id/goBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="返回到ToolBar版" /&
&/RelativeLayout&
&/LinearLayout&
Style样式:有ActionBar
&style name="AppThemeActionBar" parent="Theme.AppCompat.Light.DarkActionBar"&
&!-- Customize your theme here. --&
&item name="colorPrimary"&@color/colorPrimary&/item&
&item name="colorPrimaryDark"&@color/colorPrimaryDark&/item&
&item name="colorAccent"&@color/colorAccent&/item&
主程序代码:
public class DemoActionBarActivity extends AppCompatActivity {
private Button mB
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_actionbar);
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.KITKAT) {
WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
initView();
private void initView() {
mBtn = (Button) findViewById(R.id.goBack);
mBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
这样ActionBar就实现了样式改变。
文章对应的项目地址:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具

我要回帖

更多关于 ios导航栏透明 的文章

 

随机推荐