-4

I am trying to remove the title bar like this: android:theme="@android:style/Theme.NoTitleBar"

But it doesn't work.

TRiG
  • 10,148
  • 7
  • 57
  • 107
Rika
  • 333
  • 2
  • 5
  • 19

5 Answers5

1

try this in manifest file :

<activity android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
Bapusaheb Shinde
  • 839
  • 2
  • 13
  • 16
1

You should define your application style in styles.xml file, and not in individual layout files. Here's an example from one of my projects:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- 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:windowActionBarOverlay">true</item>
        <item name="colorControlActivated">@color/colorSecondaryDark</item>
    </style>

</resources>
lidkxx
  • 2,731
  • 2
  • 25
  • 44
0

Android manifest.xl when u adding activity add this code

<activity
        android:name=".activity.MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
phpdroid
  • 1,642
  • 1
  • 18
  • 36
0

1.apply this theme to remove whole title bar in your style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

than apply ti your activity like this

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">

2. try this for full screen activity

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.activitymain);
    }

3. also try this

<activity android:name=".YourActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

also you can try this in your activity before setContentView:

//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);

//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here); 
Bapusaheb Shinde
  • 839
  • 2
  • 13
  • 16