Overlaying content above AppBarLayout using new Material Design

后端 未结 4 720
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 10:02

I want to achieve something like that. (not the FAB or the Snackbar). How can i create a layout, overlaying the AppBarLayout? Like this! (For Example)

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 10:42

    I had a similar requirement and I achieved it as below.

    Your activity theme should extend Theme.AppCompat.Light.NoActionBar. I created a Layout XML File as:

    
    
    
    
        
    
            
    
                
            
        
    
    

    And the Activity should be something like this:

    public class MainActivity extends ActionBarActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Toolbar maintoolbar = (Toolbar) findViewById(R.id.toolbar_main);
            setSupportActionBar(maintoolbar);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }
    

    I got a view like this : enter image description here

提交回复
热议问题