android studio怎么做沉浸式状态栏

 我来答
智慧性难圆0
2016-02-27 · TA获得超过1172个赞
知道大有可为答主
回答量:975
采纳率:0%
帮助的人:1127万
展开全部
答:沉浸式通知栏Android4.4以上才支持的新特性。4.3不支持。 具体实现方式如下: 1.新建个公共style,设置android:fitsSystemWindows=true true 2. 修改AndroidManifest.xml,让所有的activity样式默认设置为AppBaseTheme(*不同项目要灵活处理,笔...
ZESTRON
2025-02-18 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸... 点击进入详情页
本回答由ZESTRON提供
好程序员
2016-02-29 · HTML5前端培训/大数据培训/Java
好程序员
好程序员是IT高端课程培训基地,从平凡到卓越,为梦想而拼搏。
向TA提问
展开全部
studio,中引入沉浸式兼容库
compile ‘com.readystatesoftware.systembartint:systembartint:1.0.3’
eclipse,可以导入相应的那个类。
第一类,兼容actionbar
第一步:设置activity主题android:theme=”@style/ActionBarTheme”
<style name="ActionBarTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="android:Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/actionbar_bg</item>
</style>

第二步:设置状态栏透明,然后设置状态栏沉浸的颜色
@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);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
setTranslucentStatus(true);
}

SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
//设置沉浸的颜色 tintManager.setStatusBarTintResource(R.color.statusbar_bg);}

第三步:设置适应windows,在布局文件设置
android:fitsSystemWindows=”true”
如果不设置,应用的ui会顶上去,顶进system ui
ok
第二类 没有actionbar的activity
第一步,设置主题,android:theme=”@style/FullBleedTheme”
<style name="FullBleedTheme" parent="android:Theme.Holo.Light.NoActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<style name="FullBleedTheme" parent="android:Theme.Holo.Light.NoActionBar.TranslucentDecor">
<!-- API 19 theme customizations can go here. -->
</style>

或者
用toolbar只能设置Theme.AppCompat.NoActionBar主题
<style name="AppThemeToolbar" parent="Theme.AppCompat.NoActionBar">
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#2196F3</item>
<!--<item name="colorPrimaryDark">#1565C0</item>-->
<item name="colorAccent">#E91E63</item>
</style>

第二步:同上一个第二步。
设置状态栏透明+颜色
mTintManager = new SystemBarTintManager(this);
mTintManager.setStatusBarTintEnabled(true);
mTintManager.setNavigationBarTintEnabled(true); mTintManager.setStatusBarTintResource(R.color.statusbar_bg);
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式