导航栏下方的BottomNavigationBar

时间:2018-09-12 12:05:09

标签: android android-layout styles navbar bottomnavigationview

目标

1)使状态栏透明-完成

2)使BottomNavigationViewNavbar具有相同的颜色。 -几乎完成

问题

通过在我的Activity中添加以下代码,状态栏将变为透明。但是BottomNavigationView落在NavBar下方。如果删除此行代码,StatusBar将不再透明。你在这里感到我的痛苦吗?此外...我该如何使布局的 TOP 进入状态栏下方?

活动中的代码:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    Window w = getWindow();
    w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, 
    WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}

活动XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">

<com.custom.app.view.ClickableViewPager
    android:id="@+id/view_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/tab_layout" />

<android.support.design.widget.BottomNavigationView
    android:id="@+id/tab_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="@color/custom_black"
    app:itemIconTint="@color/white"
    app:itemTextColor="@color/white"
    app:menu="@menu/bottom_navigation_main" />

</android.support.design.widget.CoordinatorLayout>

The Style.xml

<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:textColorPrimary">@color/md_white_1000</item>
    <item name="android:actionMenuTextColor">@color/custom_black</item>
    <item name="actionMenuTextColor">@color/custom_black</item>
    <item name="android:alertDialogStyle">@style/AppTheme.AlertDialog</item>
    <item name="colorControlNormal">@color/md_white_1000</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowTranslucentNavigation">false</item>
    <item name="android:navigationBarColor">@color/custom_black</item>
</style>

enter image description here

0 个答案:

没有答案