I tried all the solutions but still unable to show icon on toolbar, in my main project I have a toolbar and under it toolbar and inside toolbar, fragments, no matter what I tried I'm unable to show icon on toolbar, here is mainActivity.java which extends AppCompatActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_act_main_screen);
Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
setSupportActionBar(myToolbar);
ActionBar ab = getSupportActionBar();
ab.setTitle("Title");
tabs = (TabLayout) findViewById(R.id.tabs);
tabs.addTab(tabs.newTab().setText("Today"),true);
tabs.addTab(tabs.newTab().setText("Settings"));
tabs.setOnTabSelectedListener(this);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>
menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="address">
<item
android:id="#+id/action_settings"
android:title="#string/action_settings"
app:showAsAction="always"
//android:showAsAction="always" tried this as well
android:icon="#drawable/share"/>
mainactivity.xml
<android.support.v7.widget.Toolbar
android:id="#+id/my_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/toolbarColor"
android:elevation="3dp">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed"
/>
Nothing is working, not sure abou how to implement custom namespace but I changed name from app to custom but didn't work also there is enough space but still doesn't show.
I always do this for toolbar's title and icon :
Because I don't have access to a computer right now , I cant post a complete sample but I'll describe :
First set your toolbar height like this : layout_height="android:?attr/actionBarSize" then in the android.support.v7.widget.Toolbar tag put a LinearLayout with these attributes : android:layout_width="match_parent and android:layout_height="match_parent" and android:gravity="center_vertical|left" then put an ImageView in the LinearLayout with these attributes:
width="wrap_content"
height="match_parent"
scaleType="fitXY"
adjustviewbounds="true"
src="#drawable/icon"
if you want to add a title just add a text view after adding the ImageView.
On your activity class you need this :
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu, menu);
return true;
}
Try to use both
android:showAsAction="always"
app:showAsAction="always"
Ignore the warning that you should use app:showAsAction
Related
I've been trying to figure out how the default Navigation Drawer Activity template came with Android Studio navigates between different fragments. I understand that this menu is an implementation using AndroidX navigation component and navigation graph, but I just cannot understand how each menu item is mapped to its corresponding fragment. I don't see any listener or onNavigationItemSelected() etc. Can someone explain how the mapping between menuItem and corresponding fragment was achieved?
MainActivity.java:
public class MainActivity extends AppCompatActivity {
private AppBarConfiguration mAppBarConfiguration;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
mAppBarConfiguration = new AppBarConfiguration.Builder(
navController.getGraph())
.setDrawerLayout(drawer)
.build();
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
}
#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;
}
#Override
public boolean onSupportNavigateUp() {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
return NavigationUI.navigateUp(navController, mAppBarConfiguration)
|| super.onSupportNavigateUp();
}
}
menu.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
>
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_home"
android:icon="#drawable/ic_menu_camera"
android:title="#string/menu_home" />
<item
android:id="#+id/nav_gallery"
android:icon="#drawable/ic_menu_gallery"
android:title="#string/menu_gallery" />
<item
android:id="#+id/nav_slideshow"
android:icon="#drawable/ic_menu_slideshow"
android:title="#string/menu_slideshow" />
</group>
</menu>
nav_graph.xml
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/mobile_navigation"
app:startDestination="#+id/nav_home">
<fragment
android:id="#+id/nav_home"
android:name="com.buzzz.myapplication.ui.home.HomeFragment"
android:label="#string/menu_home"
tools:layout="#layout/fragment_home">
<action
android:id="#+id/action_HomeFragment_to_HomeSecondFragment"
app:destination="#id/nav_home_second" />
</fragment>
<fragment
android:id="#+id/nav_home_second"
android:name="com.buzzz.myapplication.ui.home.HomeSecondFragment"
android:label="#string/home_second"
tools:layout="#layout/fragment_home_second">
<action
android:id="#+id/action_HomeSecondFragment_to_HomeFragment"
app:destination="#id/nav_home" />
<argument
android:name="myArg"
app:argType="string" />
</fragment>
<fragment
android:id="#+id/nav_gallery"
android:name="com.buzzz.myapplication.ui.gallery.GalleryFragment"
android:label="#string/menu_gallery"
tools:layout="#layout/fragment_gallery" />
<fragment
android:id="#+id/nav_slideshow"
android:name="com.buzzz.myapplication.ui.slideshow.SlideshowFragment"
android:label="#string/menu_slideshow"
tools:layout="#layout/fragment_slideshow" />
</navigation>
Thank you very much.
As per the Update UI components with NavigationUI documentation, the setupWithNavController() methods hook up UI elements (such as your NavigationView) with the NavController.
Looking at the setupWithNavController() Javadoc:
Sets up a NavigationView for use with a NavController. This will call onNavDestinationSelected when a menu item is selected. The selected item in the NavigationView will automatically be updated when the destination changes.
So internally, this is setting up the appropriate listeners - both on the NavigationView to handle menu selections and on the NavController to update the selected item when the current destination changes.
Looking at the onNavDestinationSelected() Javadoc, it becomes clear how the menu items and navigation graph destinations are matched:
Importantly, it assumes the menu item id matches a valid action id or destination id to be navigated to.
So clicking on a menu item with android:id="#+id/nav_home" will navigate to the destination with android:id="#+id/nav_home".
I created a Toolbar and a "3-dot menu" that goes on the Toolbar. In my HomeActivity, the menu displays. However, in other activities, the menu doesn't (but the Toolbar does). I'm not sure what's happening here.
Here is the toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#color/colorPrimary"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/Theme.AppCompat.Light">
</androidx.appcompat.widget.Toolbar>
Here is the settings_menu.xml that should show the 3-dot menu.
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="#+id/item2"
android:title="Item 2"
app:showAsAction="never" />
<item android:id="#+id/item3"
android:title="Item 3"
app:showAsAction="never">
<menu>
<item android:id="#+id/subitem1"
android:title="Sub Item 1"/>
<item android:id="#+id/subitem2"
android:title="Sub Item 2"/>
</menu>
</item>
</menu>
Here is the onCreate() method of HomeActivity, where the menu DOES appear.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// deactivate the fullscreen mode used by the splash screen
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
setContentView(R.layout.activity_home);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
tvClients = findViewById(R.id.tvClients);
tvClientList = findViewById(R.id.tvClientList);
tvClientName = findViewById(R.id.tvClientName);
buttonSettings = findViewById(R.id.buttonSettings);
buttonLogout = findViewById(R.id.buttonLogout);
buttonCreateNewClient = findViewById(R.id.buttonCreateNewClient);
// Initialize Firebase Auth
mAuth = FirebaseAuth.getInstance();
And here is the onCreate() method of another activity, accessed through a button click in the HomeActivity, where the menu button does NOT appear.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_new_client);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Create New Client");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
etClientFirstName = findViewById(R.id.etClientFirstName);
etClientLastName = findViewById(R.id.etClientLastName);
etClientAge = findViewById(R.id.etClientAge);
buttonCreateClient = findViewById(R.id.buttonCreateClient);
buttonCreateClient.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
createClient();
}
});
// Initialize Firebase Auth
mAuth = FirebaseAuth.getInstance();
}
you have to override the onCreateOptionsMenu in every activity you need menu to be shown within
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.settings_menu, menu);
// return true so that the menu pop up is opened
return true;
}
check this thread for full details
I have an Activity where I used a ListView to display some data and I also want to do some filtering by using SearchView and I want to display the filtered results in the same Activity.
#Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setSubmitButtonEnabled(true);
return true;
}
I am doing the search correctly but I noticed that when ever I make a new search process a new Activity instance gets created. So, I wanted to launch the Activity as singleTop by putting android:launchMode="singleTop" to my manifest and tried to handle the search process in onNewIntent method. That did not work as well. The Activity still gets created anytime I make a new search.
How can I avoid this ? Any help would be appreciated.
I'll try to give an example.
Suppose we have a layout file activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" >
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/appbar_layout"></ListView>
</RelativeLayout>
menu_main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.prateek.search.MainActivity">
<item
android:id="#+id/action_settings"
android:orderInCategory="100"
android:title="#string/action_settings"
app:showAsAction="never" />
<item
android:id="#+id/search"
android:title="Search"
app:actionViewClass="android.support.v7.widget.SearchView"
app:showAsAction="ifRoom"/>
</menu>
And here's the MainActivity.java file
public class MainActivity extends AppCompatActivity implements SearchView.OnQueryTextListener {
SearchView searchView;
ListView listView;
String[] values = {"John", "Jack", "Alfred", "Bruce", "Frank"};
ArrayAdapter<String> adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
listView = (ListView) findViewById(R.id.listView);
adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, android.R.id.text1, values);
listView.setAdapter(adapter);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setSubmitButtonEnabled(true);
searchView.setOnQueryTextListener(this);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public boolean onQueryTextSubmit(String query) {
return false;
}
#Override
public boolean onQueryTextChange(String newText) {
String text = newText;
adapter.getFilter().filter(text);
return false;
}
}
When you search any element, filtered results should be displayed in same activity. Hope it helps!
styles.xml file
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
So far, it seems that I need to provide a custom Toolbar in order to add any Button. From my meager understanding, I can only get "3 dots" to show in the right-side of the Toolbar given by the Theme. On top of that, the "3 dots" button appears to only allow a menu of items.
The following code causes a crash:
toolbar = findViewById( R.id.notes_toolbar );
setSupportActionBar( toolbar );
And thus, I get:
Caused by: java.lang.IllegalStateException: This Activity already has an action bar supplied by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead.
Avoiding a re-write of several of several class files, is there a simple way of addressing this?
Thank you kindly.
styles.xml :
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
Course_NoteTaking_Activity.java :
public class Course_NoteTaking_Activity extends AppCompatActivity {
private Button saveButton;
private EditText notes_EditText;
private Toolbar toolbar;
#Override
protected void onCreate( Bundle savedInstanceState ) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_course_notetaking );
toolbar = findViewById( R.id.notes_toolbar );
//TODO CAUSES A CRASH FROM PRE-EXISTING TOOLBAR.
//setSupportActionBar( toolbar );
//getSupportActionBar().setDisplayHomeAsUpEnabled( false );
//getSupportActionBar().setTitle( "Notes for the Course" );
Intent intent = getIntent();
String testString = intent.getStringExtra( "notes" );
saveButton = findViewById( R.id.notes_saveButtonXML );
saveButton.setOnClickListener( new View.OnClickListener() {
#Override
public void onClick( View view ) {
Intent returnIntent = new Intent();
String transferString = "Just testing... 1, 2, and a 3!!!";
returnIntent.putExtra( "return_Notes", transferString );
}
});
notes_EditText = findViewById( R.id.notes_EditTextXML );
notes_EditText.setText( testString );
}
}
activity_course_notetaking.xml :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/notes_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="4dp"
>
<Button
android:layout_width="wrap_content"
android:layout_height="8dp"
android:text="Test Button"
android:layout_gravity="right"
/>
</android.support.v7.widget.Toolbar>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical"
android:showDividers="none"
tools:context="com.weslange.Term_Scheduling.Course_ChangingDetails_Activity"
>
<Button
android:id="#+id/notes_saveButtonXML"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Return to the Course's Details (Not Saved Yet)"
android:layout_marginVertical="2dp"
/>
<EditText
android:id="#+id/notes_EditTextXML"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName|textCapWords"
android:imeOptions="actionDone"
android:layout_marginVertical="2dp"
/>
</LinearLayout>
</RelativeLayout>
it seems that I need to provide a custom Toolbar in order to add any Button
You do not need a custom Toolbar to add action bar items that show up as buttons in the action bar. You are welcome to use a Toolbar, of course, but that is not necessary.
From my meager understanding, I can only get "3 dots" to show in the right-side of the Toolbar given by the Theme
Or, you can inflate a menu resource, and add action bar items that either show up in the overflow ("3 dots") or as buttons (if there is room). This is the classic way of adding things to the action bar, and you can do it with Toolbar as well.
is there a simple way of addressing this?
In terms of the crash, don't use a theme that has an action bar. For example, you could replace parent="Theme.AppCompat.Light.DarkActionBar" with parent="Theme.AppCompat.Light.NoActionBar".
getSupportActionBar().setLogo(R.drawable.addicon);
The code above seems to place my Icon in the Centre . I would like to place to the far right and make it clickable as well . At the moment it the image for the icon is in the project files as a drawable I have not included it in any xml files.
You can set android:layoutDirection="rtl" in your toolbar xml for place it to right and
set below code for clickable :
getSupportActionbar().setDisplayHomeAsUpEnabled(true);
and :
#Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
//Do stuff
return true;
default:
return super.onOptionsItemSelected(item);
}
}
There are 2 approaches for doing that.
Option Menus
Creating custom toolbar.
With Option Menus
create main.xml under res/menu.
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.ioa.MainActivity" >
<item
android:id="#+id/action_addition"
android:icon="#drawable/addicon"
android:orderInCategory="100"
android:title="Addition"
app:showAsAction="always"/>
</menu>
and inside your activity create menu like,
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
you can perform Action on particular menu item.
#Override
public boolean onOptionsItemSelected(MenuItem Item) {
if (Item.getItemId() == R.id.action_addition) {
// perform action
}
return super.onOptionsItemSelected(paramMenuItem);
}
With custom toolbar
Create your ToolBar like this,
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/ColorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/add"
android:layout_width="46dp"
android:layout_height="46dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="4dp"
android:clickable="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
and now you can perform click event of particular ImageView.
ImageView add = (ImageView) findViewById(R.id.add);
add.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// do work.
}
});
happy Coding.
You Need 3 Things:
A Custom Toolbar Layout
Include the toolbar in your activity
Set the Logo to the toolbar
Create new Resource Layout:
include_toolbar.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/colorPrimaryDark"
android:id="#+id/include_toolbar"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
Change Your Activity File: MainActivity.java
public class BaseActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Toolbar toolbar = (Toolbar)findViewById(R.id.include_toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.mipmap_ic_launcher);
}
}
And here's the styles.xml:
<!-- language: xml-->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
</resources>