I want to show a specific text in my app toolbar but it also always shows the name of the app too. How can I get rid of the app name and only the text of the TextView
?
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay"
android:fitsSystemWindows="true" >
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
android:fitsSystemWindows="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="The title I want to show"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Add label to activity declaration in AndroidManifest.xml file.
<activity
....
android:label="Name of Your Screen"
....
</activity>
For static activity name, set android:label="Activity Name"
attribute for each activity
in AndroidManifest.xml
...
<activity
...
android:label="Activity Name">
...
</activity>
...
For dynamic activity name, you can use the following:
getActionBar().setTitle("Activity Name");
To provide compatibility across all the android versions, use:
getSupportActionBar().setTitle("Activity Name");
But if you want to completely get rid of the title bar, you can extend Activity
instead of AppCompatActivity
or you can hide the action bar:
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With