android: how to add a button with text inside collapsing toolbar

后端 未结 3 2031
醉梦人生
醉梦人生 2021-02-06 06:22

How to achieve the following layout. I could achieve without the add button. But how to add the ADD buttom and add button should disappear along with parallax of the image when

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-06 07:03

    In order to add back button (or any other button or image), you can add it to the Toolbar. If you would like to make this button shown always, whether toolbar is collapsed or not, you can add this line to the toolbar:

                    app:layout_collapseMode="pin"
    

    If you want the button to disappear when toolbar collapses, replace this line with:

                    app:layout_collapseMode="parallax"
    

    Then you can find this button/image by id from the activity/fragment and add listener to it. The full code for the Toolbar:

        
    
        
    
            
    
            
    
                
            
    
        
    
    
    

提交回复
热议问题