user2836797
user2836797

Reputation:

Have an item overlap the actionbar?

I am using the new CoordinatorLayout, AppBarLayout and Toolbar classes. I'm trying to have an image overlap the action bar. You can see in the screenshot that the actionbar is pulled down half of the screen and that the content view (an image in this case) overlaps it. Is this possible to do?

enter image description here

I've tried using a FrameLayout but it doesn't seem to work.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".MainActivity">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:drawable/ic_menu_add"/>

        <android.support.design.widget.AppBarLayout
            android:layout_height="380dp"
            android:layout_width="match_parent"
            android:theme="@style/AppTheme.AppBarOverlay">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.AppBarLayout>

    </FrameLayout>

</android.support.design.widget.CoordinatorLayout>

enter image description here

Upvotes: 1

Views: 301

Answers (1)

Gi0rgi0s
Gi0rgi0s

Reputation: 1877

Sounds like you have some familiarity with the ToolBar widget. You should consider replacing your ActionBar completely with a ToolBar. It will allow for overlapping and provide you with the same functionality as an ActionBar.

See here: http://android-developers.blogspot.kr/2014/10/appcompat-v21-material-design-for-pre.html

Upvotes: 1

Related Questions