Android 带有BottomNavigationView的渐变状态栏
在我的应用程序中,我想显示渐变状态栏。我还使用了Android 带有BottomNavigationView的渐变状态栏,android,android-layout,gradient,android-statusbar,android-bottom-nav-view,Android,Android Layout,Gradient,Android Statusbar,Android Bottom Nav View,在我的应用程序中,我想显示渐变状态栏。我还使用了BottomNavigationView。所以问题是,当我在做状态栏渐变时,android的底部导航栏与BottomNavigationView重叠 我尝试了以下解决方案: 我的代码如下: -->在java代码中,我尝试了: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow();
BottomNavigationView
。所以问题是,当我在做状态栏渐变时,android的底部导航栏与BottomNavigationView
重叠
我尝试了以下解决方案:
我的代码如下:
-->在java代码中,我尝试了:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
w.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
问题::通过这段java代码,我实现了状态栏问题,但android的底部导航栏与底部导航视图重叠
-->我还尝试了以下风格:
<item name="android:windowFullscreen">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowIsTranslucent">true</item>
问题::但它隐藏了我不想看到的状态栏和底部导航。
*******************编辑*******************
在活动中尝试:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
} else {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
在布局中:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
风格:
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:navigationBarColor">#000</item>
<item name="colorControlNormal">#FFFFFF</item>
</style>
假的
假的
真的
真的
真的
@android:彩色/透明
真的
假的
#000
#FFFFFF
任何形式的帮助都是值得的。谢谢大家! 您上面的代码对我来说运行良好 您需要更改根目录布局 将协调布局作为根布局 使用
android.support.design.widget.CoordinatorLayout
而不是
RelativeLayout
使用“相对论”查看输出
使用android.support.design.widget.Coordinator布局输出
@NileshRathod我得到的是白色状态栏,而不是你给出的答案。我给fitSystemWindow设置了不同的工具栏布局,并在底部导航视图活动中添加了此选项。同时将透明主光源设置为暗。还是不走运。你能检查一下吗?请用相关代码和预期输出编辑你的问题,这样我可以试着帮助你吗you@NileshRathod请检查编辑的问题。我的设备是6.0.1,预期输出案例的图像在哪里?make
android.support.design.widget.CoordinatorLayout
您的根布局在包含活动rest的底部导航中仍然存在相同问题。我需要在所有片段中添加此代码还是只在父活动中添加此代码?fitsystem窗口code@Annie可能是因为我没有在中测试此代码fragments@Annie为什么问新的问题不做那件事?问题kya ave che m k mne nvo问题puchi to koik重复mari desheTo问题kya ave che
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:navigationBarColor">#000</item>
<item name="colorControlNormal">#FFFFFF</item>
</style>