Android—沉浸式状态栏

我们的征程是星辰大海,而非人间烟尘

文章目录

  • Android---沉浸式状态栏
    • 去掉标题栏
      • 效果
    • 引入依赖
    • 沉浸状态栏颜色
    • 沉浸状态栏图片

去掉标题栏

首先去掉对应主题下面的Android自带的ActionBar,只需要在对应主题下面加NoActionBar

效果

引入依赖

implementation 'com.jaeger.statusbarutil:library:1.5.1'

沉浸状态栏颜色

沉浸式状态栏,既可以把颜色实现沉浸,又可以把图片实现沉浸。

未设置颜色沉浸的状态:

逻辑代码:

StatusBarUtil.setColor(MainActivity.this,getResources().getColor(R.color.teal_200),0)

布局文件


沉浸状态栏图片

未沉浸之前的效果

沉浸之后的效果

布局代码

  • 将要沉浸的图片放在ImageView组件里面
  • 其他的组件放在一个布局里面
  • 通过一个setTransparentForImageView方法替换

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><ImageViewandroid:id="@+id/imageView"android:layout_width="0dp"android:layout_height="250dp"android:src="@drawable/w"android:layout_margin="0dp"android:padding="0dp"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><androidx.constraintlayout.widget.ConstraintLayoutandroid:id="@+id/constraintLayout"android:layout_width="match_parent"android:layout_height="0dp"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toBottomOf="@+id/imageView"><Buttonandroid:id="@+id/button"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginBottom="115dp"android:text="Button"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

逻辑代码

StatusBarUtil.setTransparentForImageView(this,findViewById(R.id.constraintLayout));

StatusBarUtil官网

Android---沉浸式状态栏相关推荐

  1. 高大上的Android沉浸式状态栏?

    背景 之前做过Android沉浸式状态栏的相关需求,但是一直忙于工作,没时间系统的整理下沉浸式相关的知识,所以今天抽出时间,写一篇 Android沉浸式状态栏的文章. 何为沉浸式 沉浸式就是要给用户提 ...

  2. Android 沉浸式状态栏 实现方式二 ( 更简单 )

    以前写过一个沉浸式状态栏 的实现方式 Android 沉浸式状态栏 实现方式一 现在有个更为简单的实现方式 . 相关链接 http://www.apkbus.com/forum.php?mod=vie ...

  3. android 5.0状态栏下载地址,Android沉浸式状态栏(5.0以上系统)

    Android沉浸式状态栏(5.0以上系统) 沉浸式状态栏可以分为两种: 1.直接给状态栏设置颜色 (如下图:) 这里写图片描述 java代码形式: if (Build.VERSION.SDK_INT ...

  4. Android 沉浸式状态栏完美解决方案

    Android 沉浸式状态栏完美解决方案 参考文章: (1)Android 沉浸式状态栏完美解决方案 (2)https://www.cnblogs.com/dingxiansen/p/9929828. ...

  5. android 沉浸式开源库,Android沉浸式状态栏

    关于Android沉浸式状态栏, 网上已经有很多开源库, 虽然开源库可以解决某些特定布局下的沉浸式状态栏问题, 但是遇到比较特殊的布局就无法解决了, 所以了解一下沉浸式状态栏如何实现是有必要的. 无论 ...

  6. Android沉浸式状态栏工具类,一句代码轻松搞定

    Android沉浸式状态栏工具类,一句代码轻松搞定 博客原文及源码地址:http://jaeger.itscoder.com/android/2016/03/27/statusbar-util.htm ...

  7. Android底部菜单栏、Android沉浸式状态栏(顶部状态栏修改颜色)、自定义标题栏

    0.简介: 没有使用TabHost切换,而是变成FragmentActivity替换Fragment:沉浸式引用的git上面的jar包. 先看图片 1.底部导航栏 核心代码 <span styl ...

  8. android沉浸式 字体,Android沉浸式状态栏背景色以及字体颜色的修改

    在activity中设置透明状态栏 的思路: 1.让activity的布局全屏 此时布局会和状态栏重叠 2.让布局最上方预留出和状态栏高度一样的高度,将状态栏的背景色设置为透明 效果如下: 一般是在s ...

  9. android 沉浸式状态栏 19,Android 沉浸式状态栏 以及 伪沉浸式状态栏

    小菜最近在调整页面状态栏的效果,主要包括沉浸式状态栏和伪沉浸状态栏(同事唠嗑给定义的玩的). 前段时间整理过一篇 Android 沉浸式状态栏的多种样式,现在小菜在稍微的补充一下,都是在日常应用中测试 ...

  10. Android沉浸式状态栏(透明状态栏)最佳实现

    Android沉浸式状态栏(透明状态栏)最佳实现 在Android4.4之前,我们的应用没法改变手机的状态栏颜色,当我们打开应用时,会出现上图中左侧的画面,在屏幕的顶部有一条黑色的状态栏,和应用的风格 ...

最新文章

  1. tvm模型部署c++ 分析
  2. Java程序启动同时复制resources下文件到jar包同级目录
  3. 马克.扎克伯格的执行力
  4. No module named cv2
  5. flask 验证ok 另外一种方式
  6. total commander按文件夹大小显示
  7. python怎么输入下一行_python在指定行前插入一行
  8. UReport2 报表设计器 在线表格
  9. Mysql查询语句使用select.. for update导致的数据库死锁分析
  10. vmware复制fedora16出现网络启动错误
  11. sobol灵敏度分析matlab_灵敏度分析_使用MATLAB编写.doc
  12. 【EDM邮件营销】独立站卖家如何通过用户标签提高EDM邮件打开率
  13. python读取文件名包含某字符的文件_Python 在当前和子目录中查找文件名中包含指定字符串的文件...
  14. JAVA数字大写金额转换
  15. CURL: CURLE_COULDNT_CONNECT问题探究
  16. UVa 1025 (DAG 上的动态规划,有固定终点的最短时间,逆推法)
  17. 国家电网王继业:企业数字化发展的“3-3-4”框架
  18. (四)MySQL学习笔记——多表设计、多表查询、多表查询练习题
  19. 腾讯财付通漏洞遭黑客利用 威胁QQ彩钻等付费用户
  20. 链接投票二维码制作制作投票链接视频选举投票制作

热门文章

  1. 全网全牛批的java八股面试文(最全)堪称2022最强
  2. mybatis plus 不用写mapper.xml,即可使用crud(增删改查)
  3. 读懂系列 | 10个例子带你了解机器学习中的线性代数
  4. 干货满满:在线征稿、管理投稿的必备软件/工具
  5. 第三方支付接口,银行接口(附下载),third party bank interface
  6. UART和USART的区别(UART vs USART)
  7. 架构道术-架构师该如何做竟品分析
  8. 长三角农业一体化,从“大闸蟹联盟”开始
  9. JavaScript的if的分支语句
  10. h3c路由器修改ssh登录密码