I want to add a clickable icon/button to the left of the title in the action bar . How to do it? Following is the code with which I have added search and setting icon to the act
One thing is that by default title and app icon set into the left and other than icons sent into the right side. If you want to add your icons into the left side there is a way to them into to left side which is:
step 1. create a custom layout which having search, setting icon and your title as you want.
step 2. create a toolBar layout like:
step 3. inflate your custom layout into the toolbar like:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initToolbar();
}
private void initToolBar() {
setSupportActionBar(toolbar);
View customlayout= getLayoutInflater().inflate(R.layout.custom_layout, null);
toolbar.addView(logo);
}