I have an app implementing AppCompat v7 toolbar, The height of this toolbar on Lollipop is twice as big as on Androids < 5.0
Update: I'll add screenshots from Kitkat and Lollipop now Toolbar xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:fitsSystemWindows="true"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
theme="@style/ThemeOverlay.AppCompat.ActionBar"
>
<LinearLayout
android:padding="0dp"
android:layout_margin="0dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right|center_vertical">
<TextView
android:id="@+id/action_bar_restaurant_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/restaurant_label_action_bar_margin_start"
android:layout_weight="1"
android:alpha="0"
android:ellipsize="end"
android:gravity="left"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="@dimen/restaurant_label_action_bar_font_size" />
<ImageButton
android:id="@+id/shuffle_restaurant"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginRight="7dp"
android:layout_weight="0"
android:background="@color/transparent"
android:scaleType="fitXY"
android:src="@drawable/shuffle_button" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
My layout is as follows:
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<include layout="@layout/activity_content" />
</FrameLayout>
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="fill_parent"
android:layout_gravity="start"
android:background="@color/list_background"
android:choiceMode="singleChoice"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector"
android:paddingTop="50dp" />
</android.support.v4.widget.DrawerLayout>
Screenshot:
Ok I found the solution for this finally,
When you have a translucent Status Bar and you don't want your toolbar to go below the status bar, but instead stay in the position where the original "ActionBar" was, you'll need to set it to the following
android:fitsSystemWindows="true"
But this causes the problem I described above when setting it directly on the ToolBar, so instead I wrapped the toolbar in
<FrameLayout />
and set the
android:fitsSystemWindows="true"
on the FrameLayout not the Toolbar
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