Search code examples
androidandroid-layoutactionbarsherlock

ActionBar with No TitleBar


How to have a fullscreen application ( no title bar ) nad have actionbar for all devices? When i use

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
             WindowManager.LayoutParams.FLAG_FULLSCREEN);

actionbar removed.and if i change it to

this.requestWindowFeature(Window.FEATURE_ACTION_BAR | Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
             WindowManager.LayoutParams.FLAG_FULLSCREEN);

i have a fullscreen application with action bar BUT output is look like

https://i.sstatic.net/Ptlfw.png

and myLayout.xml :

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="20dip">
<TextView
    android:id="@+id/text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />
</LinearLayout>

By the way,i'm going to use Sherlock , and wanna ActionItems ( first item in sherlock's samples ) , but with no titlebar.


Solution

  • Put it on style.xml:

    <style name="MyTheme" parent="Theme.Sherlock.Light.DarkActionbar">
        <item name="android:windowFullScreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>
    

    And use it in manifest like this:

    <activity android:name="MainActivity" android:theme="@style/MyTheme"></activity>