Toolbar with EditText material design

前端 未结 4 1494
萌比男神i
萌比男神i 2021-01-31 05:24

I\'m trying to make Toolbar with EditText within it like this:

Right now I can do some thing similar but only with static title, Any ideas to get started?

4条回答
  •  野性不改
    2021-01-31 06:07

    You can use a linear layout with the same color of your toolbar. The toolbar attribute android:elevation needs to be 0px.

    Activity (xml)

    
    
        
    
        
    
    
    

    Toolbar (xml)

    
    
    
    

    Fragment (xml)

    
    
    
        
    
            
    
                
    
                    
    
                
    
            
    
             
    
            
    

    Activity (java)

    public class TaskActivity extends AppCompatActivity {
    
    
        @Override
        protected void onCreate(@Nullable Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            initializeTodo(savedInstanceState);
            setContentView(R.layout.activity_task);
            //set the toolbar
            setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setTitle(null);
        }
    

    The result:

提交回复
热议问题