Skip to content

Instantly share code, notes, and snippets.

@john-lorrenz
Last active November 6, 2019 10:13
Show Gist options
  • Save john-lorrenz/8f43805fc9e7e1f636d45d510e7b89ac to your computer and use it in GitHub Desktop.
Save john-lorrenz/8f43805fc9e7e1f636d45d510e7b89ac to your computer and use it in GitHub Desktop.
Built-in Action Bar Manipulation
<!-- CENTER TITLE ACTION BAR -->
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#28344E"
app:popupTheme="@style/AppTheme.PopupOverlay">
<TextView
android:id="@+id/toolbar_title"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="[Title Name]" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<!-- CHANGE TITLE -->
<activity android:name=".ActivityName"
android:label="[LABEL HERE]"/>
<!-- HIDE ACTION BAR -->
<activity android:name=".ActivityName"
android:theme="@style/AppTheme.NoActionBar"/>
<!-- DISPLAY BACK/UP BUTTON -->
<activity android:name=".ChildActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ParentActivity" />
</activity>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment