How to change toolbar title text color

In this android programming source code example, we are going to explore how to change toolbar title text color.

You can copy and adopt this source code example to your Android project without reinventing the wheel.

Below is a step by step source code to change toolbar title text color.

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
    tools:context=".toolbar.Toolbar3">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_top"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/colorAccent"
        app:popupTheme="@style/AppTheme.PopupOverlay"  >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/colorWhite"
            android:text="Toolbar Title"
            android:id="@+id/toolbar_title" />

    </android.support.v7.widget.Toolbar>

</android.support.design.widget.CoordinatorLayout>

MainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;

import com.inducesmile.inducesmile_button.R;

public class Toolbar3 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_toolbar3);
        Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar_top);
        setSupportActionBar(toolbar);
    }
}

If you have any question or suggestions kindly use the comment box or you can contact us directly through our contact page below.

 

Add a Comment