I want to display the menu icon to left of the toolbar and the search icon to be in the actual place of the menu icon
This is my main.xml file inside the main folder
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/my_search"
android:icon="@drawable/ic_search_black_24dp"
android:title="search"
app:showAsAction="always">
</item>
<item
android:id="@+id/my_menu_icon"
android:icon="@drawable/ic_menu_black_24dp"
android:title="side_menu"
app:showAsAction="always">
</item>
</menu>
This is the result of this page: my result
And this is my MainActivity.java
:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);//affect the menu file to the main activity and call this last one
return true;
}
}