Dr.jacky
Dr.jacky

Reputation: 3547

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.

Upvotes: 1

Views: 5233

Answers (4)

Dr.jacky
Dr.jacky

Reputation: 3547

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>

Upvotes: 0

user3139591
user3139591

Reputation: 96

Maybe replacing the window feature settings Window.FEATURE_NO_TITLE by Window.FEATURE_ACTION_MODE_OVERLAY setting will do the trick.

Upvotes: 1

RobinHood
RobinHood

Reputation: 10969

You have to change your parent style within abs_themes.xml

Go to@

Library>res>values>abs_themes.xml

open that file and replace a sort of code to@

<style name="Sherlock.__Theme" parent="android:Theme.NoTitleBar.Fullscreen">

instead

<style name="Sherlock.__Theme" parent="android:Theme.NoTitleBar">

Updated

Attaching output screen

enter image description here

Upvotes: 3

sujith
sujith

Reputation: 2421

What do you mean by all devices? ActionBar is introduced from Honeycomb, and it replaces the TitleBar. You can't have ActionBar in pre-Honeycomb devices. In case if you are just targeting Honeycomb and later devices, Window.FEATURE_NO_TITLE actually removes the ActionBar, so please don't use Window.FEATURE_NO_TITLE for your ActionBar to be visible.

Upvotes: 1

Related Questions