I wanted to set the background color of my Navigation drawer in java but it seems as setBackgroundColor
and all similar methods have no effect. Only the XML line android:background="@color/mycolor"
is working. If remove the xml line and try one of the methods the drawer just stays transparent.
Any ideas?
Android App Development for BeginnersStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 3 − Add the following code to res/layout/nav_header_main.
In your activity_main.xml include the following
<android.support.design.widget.NavigationView android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" app:headerLayout="@layout/navigation_drawer_header" app:menu="@menu/menu_drawer" android:background="@color/color_navigation_list_background" app:itemIconTint="@color/color_selector_navigation_item" app:itemTextColor="@color/color_selector_navigation_item"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With