1

I have make my view in full screen in LANDSCAPE mode just like youtube application. But had a problem that I am not able to hide title bar in my application. I am not using sherlock action bar. Instead of that I am using custom Title bar.

  1. getWindow().setFlags(LayoutParams.FLAG_FULLSCREEN,LayoutParams.FLAG_FULLSCREEN)
  2. getWindow().clearFlags(LayoutParams.FLAG_FULLSCREEN)
  3. requestWindowFeature(Window.FEATURE_NO_TITLE)

I have used all these three statements. But it doesn't work.

laalto
  • 150,114
  • 66
  • 286
  • 303
Rahul
  • 41
  • 1
  • 1
  • 5

7 Answers7

5

or in second way you can add in the manifest file then there is no need to add problematically in activity class

   <activity
         android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
         />

or you can only in landscape the use this one

@Override
public void onConfigurationChanged(Configuration newConfig) 
{
    super.onConfigurationChanged(newConfig);


    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) //To fullscreen
    {
       requestWindowFeature(Window.FEATURE_NO_TITLE); 
           getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.your_layout_name);

    } 
    else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) 
    {
        // no need to fullscreen
         setContentView(R.layout.your_layout_name);

    }
}
Sunil Kumar
  • 7,086
  • 4
  • 32
  • 50
  • thanks for reply but after using this code...my every view has multiple objects....and i m usind videoview so if i am using this my video view will buffer again an i don't want this thing.... – Rahul Jul 18 '13 at 05:55
  • 2
    use in manifest file android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout|uiMode" – Sunil Kumar Jul 18 '13 at 06:02
  • i have only one layout for both portrait and landscape due to that i m not use uiMode – Rahul Jul 18 '13 at 06:10
2

use these in onCreate() Before setContentView();

like

 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.your_layout_name);
    }
Tarsem Singh
  • 14,139
  • 7
  • 51
  • 71
  • 2
    thanks @Tarsem for reply......BUt i want to hide my action bar after calling setContentView().... in onConfigure method – Rahul Jul 18 '13 at 05:43
2

Using this:

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

before setContentView() !

Niraj Adhikari
  • 1,678
  • 2
  • 14
  • 28
2

I solved my problem with this:

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

super.onCreate(savedInstanceState);
Jorge Freitas
  • 790
  • 10
  • 18
1

I was also trying to hide Action Bar on Android 2.2, but none of these solution worked. Everything ends with a crash. I checked the DDMS LOg, It was telling me to use 'Theme.AppCompat'.At last I Solved the problem by changing the android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"Line

into android:theme="@style/Theme.AppCompat.NoActionBar"and it worked, but the the Interface was dark.

then i tried android:theme="@style/Theme.AppCompat.Light.NoActionBar" and finally got what i wanted.

After that when I Searched about 'AppCompat' on Developer Site I got This.

So I think the Solution for Android 2.2 is

<activity
    android:name=".MainActivity"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

And Sorry for my bad English Like Always.

S.Ahsan
  • 389
  • 3
  • 15
0

You can define Theme in menifest.xml for full screen.

    <activity
        android:name=".MainActivity"
        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Muhammad Aamir Ali
  • 20,419
  • 10
  • 66
  • 57
  • thanks for reply @MuhammadAamirALi,Read my question properly Actually I want to change my activity fullscreen notitlebar in landscape mode so if u change in portrait again then title bar is visible to u.... – Rahul Jul 18 '13 at 05:41
-2

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

super.onCreate(savedInstanceState);

This actually work referring to Jorge Freitas, I can't vote him up because i don't have enough "reputation"....