7

i want to set my Activity full Screen with Title bar , how can i do this ? thanks

Ken White
  • 123,280
  • 14
  • 225
  • 444
mahdi
  • 16,257
  • 15
  • 52
  • 73

5 Answers5

11

In styles.xml:

<resources>
   <style name="Theme.FullScreen" parent="@android:style/Theme.Holo">
   <item name="android:windowNoTitle">false</item>
   <item name="android:windowFullscreen">true</item>
   </style>
</resources>

Refer to your custom style in your mainfest:

<activity android:name=".MyActivity" android:theme="@style/Theme.FullScreen"/>

To be truthful I've not tested this combination myself.

AC Arcana
  • 366
  • 2
  • 10
  • That works great, did exactly what I needed. Some extra information for anyone looking to use this, if you dont have a styles.xml yet you can create a file under values and put this in there. The filename does not matter as the system accesses it by the style name. – Andy Jan 02 '14 at 22:09
2

This worked for me:

// Remove System bar (and retain title bar)
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                     WindowManager.LayoutParams.FLAG_FULLSCREEN);

In code it would look like this:

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Remove System bar (and retain title bar)
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // Set your layout
        setContentView(R.layout.main);
    }
}
Alexander Pacha
  • 9,187
  • 3
  • 68
  • 108
1

To create a full screen app with a custom title style, override some attributes of a full screen theme like so:

<style name="AppTheme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen">
    <item name="android:windowNoTitle">false</item>
    <item name="android:windowTitleSize">45dip</item>
    <item name="android:windowTitleBackgroundStyle">@style/TitleBackgroundStyle</item>
</style>

<style name="TitleBackgroundStyle">
    <item name="android:background">@drawable/title</item>
</style>

and modify as you wish.

jhoanna
  • 1,797
  • 25
  • 25
0

I suggest you to set fullscreen theme for activity e.g. Theme.Black.NoTitleBar.Fullscreen and create custom title bar in activity layout.

Martin Vandzura
  • 3,047
  • 1
  • 31
  • 63
0

Set your App theme as Theme.Holo.Compactmenu to make your title bar visible along with the icon

codeX
  • 4,842
  • 2
  • 31
  • 36