Skip to content

Instantly share code, notes, and snippets.

@sharifulislam52
Last active March 5, 2018 16:51
Show Gist options
  • Save sharifulislam52/8db0b20bd8cb804d2d38d50096d62b79 to your computer and use it in GitHub Desktop.
Save sharifulislam52/8db0b20bd8cb804d2d38d50096d62b79 to your computer and use it in GitHub Desktop.
//import android.support.v7.widget.Toolbar;
public void all_about_toolbar(){
/**
* create Toolbar and set Title, subTitle, textColor
*/
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar_id);
toolbar.setTitle("app_title");
setSupportActionBar(toolbar);
toolbar.setTitleTextColor(Color.COLOR_NAME);
/**
* set up button
*/
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
// toolbar, toolbar_id, app_title, COLOR_NAME
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- 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.Toolbar" parent="AppTheme">
<!--This line changes the color of text in Toolbar-->
<item name="android:textColorPrimary">@color/white</item>
<!--This line changes the color of icons in toolbar (back, overflow menu icons)-->
<item name="android:textColorSecondary">@color/white</item>
</style>
<?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:id="@+id/toolbar_id"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:theme="@style/AppTheme.Toolbar">
</android.support.v7.widget.Toolbar>
<!-- toolbar_id, colorPrimary -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment