BottomNavigationBar underneath NavBar
The reason your BottomNavigationView
hiding behind NavBar
because your are setting this flags
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
SEE the result using that flags
SIMPLE SOLUTION
To make your statusbar
transparent just use <item name="colorPrimaryDark">@android:color/transparent</item>
and use below flags
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
Root layout
You need to use android.support.design.widget.CoordinatorLayout
as your rootlayout
CartActivity
public class CartActivity extends AppCompatActivity {
BottomNavigationView bottomNavigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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);
}
setContentView(R.layout.activity_cart);
bottomNavigationView = findViewById(R.id.tab_layout);
}
}
layout.activity_cart
<?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:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#199bd2"
android:fitsSystemWindows="true">
<android.support.design.widget.BottomNavigationView
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="#000"
app:itemIconTint="#FFFFFF"
app:itemTextColor="#FFFFFF"
app:menu="@menu/bottom_navigation_main" />
</android.support.design.widget.CoordinatorLayout>
CustAppTheme2
<style name="CustAppTheme2" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@android:color/transparent</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorControlNormal">#FFFFFF</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>
</style>
Finally OUTPUT
Finally OUTPUT on kitkat
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…