Reputation: 117
My AndroidManifest.xml code is as follows :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.chintan.myapplication">
<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=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
My MainActivity.java code is as follows:
package com.example.chintan.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
And my app looks something like this.. I want the "Armour" to be written at the top of the screen just below the notification bar. App looks like this
Upvotes: 3
Views: 70
Reputation: 2355
1- create a FullScreenTheme inside styles.xml
<style name="FullScreenTheme" parent="your parent them"> // for example use this parent them --> Theme.AppCompat.Light.DarkActionBar
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
2- add the theme in the menefist
<activity
android:name=".MainActivity"
android:theme="@style/FullScreenTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Upvotes: 1
Reputation: 917
As I can see your app image you did not remove actionbar from your app theme. Use Theme.AppCompat.Light.NoActionBar theme for not action bar. Then if you want action bar in any activity of your app then use ToolBar .
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowIsTranslucent">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Hope this will help you.
Upvotes: 0
Reputation: 306
Change your AppTheme as following
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
</style>
Upvotes: 0
Reputation: 1001
Use this simple function and get rid of all problems
public void setFullscreen(boolean fullscreen) {
WindowManager.LayoutParams attrs = getWindow().getAttributes();
if (fullscreen) {
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
AdHelper.bannerAd.setVisibility(View.GONE);
} else {
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
if (AdHelper.isBannerLoaded)
AdHelper.bannerAd.setVisibility(View.VISIBLE);
}
getWindow().setAttributes(attrs);
}
Just Pass the parameters to true
for fullscreen and false
for exit fullscreen. That's it.
Upvotes: 0
Reputation: 158
You could try something like this:
// Make fullscreen
int UI_OPTIONS = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
getWindow().getDecorView().setSystemUiVisibility(UI_OPTIONS);
I use it to make my apps fullscreen and it works really well. It hides the nav bar and will only appear when you swipe upwards near the bottom of your device's screen
Upvotes: 0