1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Android 设置系统SystemUI 顶部StatusBar状态栏透明一体化

Android 设置系统SystemUI 顶部StatusBar状态栏透明一体化

时间:2019-01-25 17:28:24

相关推荐

Android 设置系统SystemUI 顶部StatusBar状态栏透明一体化

参考链接

/misly_vinky/article/details/12161075

这样修改的确能够把SystemUI StatusBar变成透明的但是有一个弊端就是会导致你的其他白色应用打开的时候,当前的StatusBar就会透明和白色混着一起导致看的很刺眼

SystemBarTintManager.java

Android 4.4 以上版本可以设置透明

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {

setTranslucentStatus(true);

SystemBarTintManager tintManager = new SystemBarTintManager(this);

tintManager.setStatusBarTintEnabled(true);

tintManager.setStatusBarTintResource(R.color.top_bg_color);//通知栏所需颜色

}

@TargetApi(19)

private void setTranslucentStatus(boolean on) {

Window win = getWindow();

WindowManager.LayoutParams winParams = win.getAttributes();

final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;

if (on) {

winParams.flags |= bits;

} else {

winParams.flags &= ~bits;

}

win.setAttributes(winParams);

}

我自己处理的方法,就是通过Launcher去发送连个广播,去处理,去监听Launcher的生命周期会发现

当你开启其他应用的时候,执行的是onPause()方法,当返回Launcher的时候执行的是onRestart()方法, /frameworks/base/package/SystemUI/…. PhoneStatusBar.java

//sendBroadcast change systemUI statusbar color start

Intent intent=new Intent(“change_statusbar_black”);

sendBroadcast(intent);

status_bar.xml

的默认背景色是透明的

PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);

mBroadcastReceiver.onReceive(mContext,

new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF));

// receive broadcasts

// receive broadcasts

IntentFilter filter = new IntentFilter();

filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);

filter.addAction(Intent.ACTION_SCREEN_OFF);

filter.addAction(Intent.ACTION_SCREEN_ON);

filter.addAction(ACTION_DEMO);

//add action to change statusbar color start

filter.addAction(“change_statusbar_transparent”);

filter.addAction(“change_statusbar_black”);

//add action to change statusbar color end

context.registerReceiver(mBroadcastReceiver, filter);

private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {

public void onReceive(Context context, Intent intent) {

if (DEBUG) Log.v(TAG, "onReceive: " + intent);

String action = intent.getAction();

Xlog.d(TAG, “onReceive, action=” + action);

if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {

int flags = CommandQueue.FLAG_EXCLUDE_NONE;

if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) {

总结

最后小编想说:不论以后选择什么方向发展,目前重要的是把Android方面的技术学好,毕竟其实对于程序员来说,要学习的知识内容、技术有太多太多,要想不被环境淘汰就只有不断提升自己,从来都是我们去适应环境,而不是环境来适应我们!

这里附上我整理的几十套腾讯、字节跳动,京东,小米,头条、阿里、美团等公司的Android面试题。把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。

由于篇幅有限,这里以图片的形式给大家展示一小部分。

详细整理在GitHub可以见;

Android架构视频+BAT面试专题PDF+学习笔记

网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。

见;

Android架构视频+BAT面试专题PDF+学习笔记

网上学习 Android的资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。希望这份系统化的技术体系对大家有一个方向参考。

技术进阶之路很漫长,一起共勉吧~

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。