Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Full Screen Activity with Title bar

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

like image 641
mahdi Avatar asked Oct 05 '12 22:10

mahdi


2 Answers

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.

like image 83
AC Arcana Avatar answered Nov 12 '22 21:11

AC Arcana


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);
    }
}
like image 24
Alexander Pacha Avatar answered Nov 12 '22 21:11

Alexander Pacha