Toolbar with EditText material design

前端 未结 4 1467
萌比男神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:02

    I have done this like below:

    There is Toolbar as AppBar (aka ActionBar) at the top and second toolbar below it with two EditText. First Toolbar is under CollapsingToolbarLayout in case you want it to be collapsed.

    Java:

    public class MainActivity extends AppCompatActivity {
        Toolbar toolbar;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            toolbar = (Toolbar) findViewById(R.id.toolbar_1);
            setSupportActionBar(toolbar);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setTitle("");
        }
    
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
    }
    

    activity_main.xml:

    
    
        
    
            
    
    
                
                
    
            
    
            
    
                
    
                    
    
                        
                    
    
                    
    
                        
                    
    
    
                
            
    
        
    
    
    
    

    Colors:

    
    
        #303F9F
        #3F51B5
        #00E5FF
    
    
    

    And styles.xml:

    
            
    
    

    Use android:theme="@style/AppTheme" for application in manifest and android:theme="@style/AppTheme.Base" forMainActivity`.

提交回复
热议问题