--Set characters --Change the font color
activity_main.xml
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"/>
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar=findViewById(R.id.toolbar);
toolbar.setTitle("Enter the character you want to set here");
setSupportActionBar(toolbar);
}
It is also possible to call the characters in String.xml by removing the double quotation marks in parentheses and setting it to [R.string. ○○].
In that case, you may try importing android.support.v7.widget.Toolbar, or set the minimum supported android version to API21.
I set the characters earlier, but now I will set the colors.
MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar=findViewById(R.id.toolbar);
toolbar.setTitle("Enter the character you want to set here");
toolbar.setTitleTextColor(rgb(255,255,255));
setSupportActionBar(toolbar);
}
The trick is to specify RGB instead of HTML color. The above is white, but you can set it to many other colors. Let's set it according to your preference. You can read from color.xml by setting [R.color. ○○]. This way you can use HTML color.
At first, you might think that ToolBar was easy for those who thought it was difficult. See you again! Then !!!
Author's Google+ Author's Twitter
Recommended Posts