沉浸式状态栏,既可以把颜色实现沉浸,又可以把图片实现沉浸。
引入依赖
implementation ‘com.jaeger.statusbarutil:library:1.5.1’
未设置颜色沉浸的状态:
核心代码:
StatusBarUtil.setColor(MainActivity.this,getResources().getColor(R.color.bisque),0);
设置完成后的状态栏:
========================================================================
未沉浸之前的效果:
设置完成后的状态栏:
核心代码:
StatusBarUtil.setTranslucentForImageView(this, 0, constraintLayout);
MainActivity代码
public class MainActivity extends AppCompatActivity {
ConstraintLayout constraintLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
constraintLayout=findViewById(R.id.constraintlayout);
StatusBarUtil.setTranslucentForImageView(this, 0, constraintLayout);
}
}
XML代码
<?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”>
<ImageView
android:id=“@+id/imageView3”
android:layout_width=“match_parent”
android:layout_height=“300dp”
app:layout_constraintEnd_toEndOf=“parent”
app:layout_constraintStart_toStartOf=“parent”
app:layout_constraintTop_toTopOf=“parent”
app:srcCompat=“@drawable/fengjing” />
<androidx.constraintlayout.widget.ConstraintLayout
android:id=“@+id/constraintlayout”
android:layout_width=“match_parent”
android:layout_height=“match_parent”>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
详细方法参考官方文档
[
超强干货来袭
云风专访:近40年码龄,通宵达旦的技术人生
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)
![](https://i-blog.csdnimg.cn/blog_migrate/adde1cf3885a4a842973ca14fb77f8cb.jpeg)
最后是今天给大家分享的一些独家干货:
【Android开发核心知识点笔记】
【Android思维脑图(技能树)】
【Android核心高级技术PDF文档,BAT大厂面试真题解析】
【Android高级架构视频学习资源】
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门即可获取!
711775079281)]
【Android核心高级技术PDF文档,BAT大厂面试真题解析】
[外链图片转存中…(img-KOU2tVI4-1711775079281)]
【Android高级架构视频学习资源】