How to add a navigation drawer?

后端 未结 4 985
别跟我提以往
别跟我提以往 2021-01-07 06:23

In the following activity, i have a fragment and an image on it. The Fragment is just a darker Action Bar that has a picture on it. I\'m trying to have a left slide menu as

4条回答
  •  北海茫月
    2021-01-07 06:57

    Step - 1 add lines into app level Build.gradle

      implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
        implementation 'androidx.navigation:navigation-fragment:2.3.0'
        implementation 'androidx.navigation:navigation-ui:2.3.0'
        implementation 'com.google.android.material:material:1.1.0'
    

    Step - 2 file add below code into activity_main.xml

    
    
    
        
    
        
        
    
    

    Step - 3 add below code into layout/app_bar_main.xml

    
    
    
        
    
            
        
    
        
    
    

    Step - 4 add below code into layout/nav_header_main2.xml

    
    
    
        
    
        
    
    

    Step - 5 add below code into menu/activity_main_drawer2.xml

     
    
        
            
            
            
            
            
            
        
    
    

    Step - 6 add below code into styles.xml