android 导航栏半透明,Android屏幕适配之状态栏导航栏半透明、全透明(5.0以上去阴影),方法多样...

本文详细介绍了在Android应用中实现状态栏和导航栏半透明及全透明的方法,包括使用StatusBarView、setStatusBarColor、fitSystemWindows等不同方式,并提供了适用于不同Android版本的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用方法

1.工程目录下的build.gradle中添加代码:

allprojects {

repositories {

maven { url 'https://jitpack.io' }

}

}

2.直接在需要使用的模块的build.gradle中添加代码:

注意:记得去gayhub查看最新版本,最新版本最niubility

implementation 'com.github.AnJiaoDe:StatusNavigationTransparent:V1.1.7'

ae5ca0c2bc35751a731fea689d4653d1.png

本文只描述在activity中如何使用,fragment中使用方法类似,可以实现

首先创建全局theme

@color/colorPrimary

@color/colorPrimaryDark

@color/theme

@color/white

stateAlwaysHidden

@color/text_deep

@dimen/size_3

centerInside

singleTop

android:allowBackup="true"

android:icon="@mipmap/ic_launcher"

android:label="@string/app_name"

android:supportsRtl="true"

android:theme="@style/AppTheme">

然后创建BaseActivity实现StatusBar全透明

public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener {

@Override

protected void onCreate(@Nullable Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

StatusNavUtils.setStatusBarColor(this,0x00000000);

}

public void startAppcompatActivity(Class> cls) {

startActivity(new Intent(this, cls));

}

}

1. StatusBar半透明

1.1 StatusBar半透明用StatusBarView实现(4.4以上有效)

59a021cb0d77922714f572f9930fdf54.png

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/colorPrimary"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="#33000000" />

android:layout_width="match_parent"

android:layout_height="48dp"

android:background="@color/colorPrimary">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:gravity="center"

android:text="StatusBar半透明(statusBarView)"

android:textColor="#ffffff" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/white"

android:orientation="vertical">

1.2 StatusBar半透明用setStatusBarColor实现(5.0以上有效)

db2cc54dd5ede350f9e3286e132b50a9.png

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/colorPrimary"style="@style/transparent_statusbar_fit"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="48dp"

android:background="@color/colorPrimary">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:gravity="center"

android:text="StatusBar半透明(setStatusBarColor

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值