Why does my Action Bar not overlay?

Viewed 790

I am new to Android development. I have followed the Android Overlay training at:

http://developer.android.com/training/basics/actionbar/overlaying.html

and spent the last few days trying to get this to work. I am using the AppCompat library and my min SDK is 7 and my max sdk is 18.

My application defines a custom style and looks like this:

<application

android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/CustomActionBarTheme" >

<activity
android:name="com.example.rtrt.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

My layout looks like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/button_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/clickme"
android:onClick="sendMessage" />
</RelativeLayout>

My theme.xml looks like this:

<style name="CustomActionBarTheme"  
parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item> 
</style>      <!-- ActionBar styles -->

<style name="MyActionBar"            
parent="@style/Widget.AppCompat.Light.ActionBar">

<item name="android:background">@android:color/transparent</item>

<item name="android:windowActionBarOverlay">true</item>

<!-- Support library compatibility -->
<item name="windowActionBarOverlay">true</item>   
</style>

The application compiles and runs... however, the Button appears below (not under) the ActionBar. When I hide the ActionBar the Button moves to the top of the screen. When the ActionBar is made visible, the Button is repositioned down the screen.

Why is my ActionBar not floating (overlaying)?

Would appreciate any help here.

1 Answers
Related