android - Toolbar title full width -
how/is possible make title span whole width of toolbar? text cut off menu items.
ive tried playing around different xml attributes such paddingend
, contentinsetright
, titlemarginend
no result.
thanks! :)
normally, title has fit between toolbar's menu & action items in order move title when toolbar collapsing.
an easy way around put textview inside toolbar , set toolbar's background transparent. notice how i've set elevation linearlayout , disabled on toolbar (although shadow isn't visible in screenshot since running on kitkat device).
<!-- app bar container --> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/blue" android:elevation="2dp" android:orientation="vertical"> <!-- app bar --> <android.support.v7.widget.toolbar android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent" android:elevation="0dp" android:gravity="center" android:minheight="?attr/actionbarsize"> </android.support.v7.widget.toolbar> <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginbottom="6dp" android:layout_marginleft="20dp" android:layout_marginright="20dp" android:text="title below appbar itself." android:textcolor="#fff" android:textsize="20sp"/> </linearlayout>
which gives following result:
this might 2 views, keep in mind if don't set title toolbar, no textview inflated there. net result still 1 view though.
Comments
Post a Comment