1

I need to set my activity into fullscreen no statusbar and actionbar

here is my code base on what i have google. I added NoTitleBar and Fullscreen

   <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"  
         android:theme="@android:style/Theme.NoTitleBar"  >
        <activity
            android:name="com.examples.hello.MainActivity"
            android:label="@string/app_name" 
             android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

The problem is my app crushes about Theme.AppCompat. How do i fix this one?

my log

> 04-09 11:22:35.570:  E/AndroidRuntime(3931): 
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{com.examples.hello/com.examples.hello.MainActivity}:
> java.lang.IllegalStateException: You need to use a Theme.AppCompat
> theme (or descendant) with this activity.
user3487657
  • 553
  • 2
  • 8
  • 17

2 Answers2

1

Try this:

Pragmatically :

    public class ActivityName extends Activity {
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);

           // remove title
           requestWindowFeature(Window.FEATURE_NO_TITLE);
           getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

           setContentView(R.layout.main);
    }
  }

By XML in Manifest file:

<activity android:name=".ActivityName"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>
Lavekush Agrawal
  • 6,040
  • 7
  • 52
  • 85
  • Remove this from manifest file `android:theme="@android:style/Theme.NoTitleBar.Fullscreen"` and use Pragmatically aproach for doing this: or you can pls follow this link http://stackoverflow.com/questions/17870881/cant-find-theme-appcompat-light-for-new-android-actionbar-support – Lavekush Agrawal Apr 09 '14 at 03:58
0
@Override
protected 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.yourlayoutname);
}

put this code in to your onCreate method in your MainActivity before you setContentView.

Tharindu Welagedara
  • 2,660
  • 18
  • 27