Friday, 23 August 2013

How to display app in Full Screen by removing the title bar and navigation bar...

Developing a game? Then turn your device into a playground...



Please Note: The images are taken from Pixabay.

----------------------------------In the full_screen_activity.xml file-----------------------------------
<?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:background="@drawable/animalbg"
android:orientation="vertical" >
</LinearLayout>
----------------------------------------------------------------------------------------
--------------------------------------------In FullScreenActivity.java------------------------------------------------
package com.app.yourappname;

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

public class FullScreenActivity extends Activity {

@Override
public void onCreate(Bundle b) {
super.onCreate(b);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.full_screen_activity);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
----------------------------------------------------------------------------------------

----------------------------------------Declare the Activity name in Manifest file------------------------------
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.yourappname">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".FullScreenActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
----------------------------------------------------------------------------------------

No comments:

Post a Comment