EDIT: I now have a custom Toolbar
in a separate layout (toolbar.xml
) from that of my activity_main.xml
. The new layout now contains just one TextView
for the title. The Toolbar
however, has an overflow menu
which contains only one item (the settings icon) and it's set to showAsAction="always"
. However, in the layout preview i can't see the actual settings icon thus i'm not able to align
my title TextView
with the icon in order to avoid any misalignments (see image). Any ideas?
toolbar.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="@drawable/toolbar_gradient"
android:elevation="4dp"
app:titleTextColor="@android:color/white"
app:layout_scrollFlags="scroll|enterAlways">
<TextView
android:id="@+id/toolbar_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/toolbar_title_placeholder"
android:fontFamily="@font/montserrat_semibold"
android:textColor="@android:color/white"
android:textSize="20sp" />
</androidx.appcompat.widget.Toolbar>
As you can see in the image below, my title TextView
is misaligned in regards to the overflow menu item
(settings icon). Is there a way i can fix that?
from Aligning an overflow menu item's icon with the Toolbar Title
No comments:
Post a Comment