Unable to delete title bar in action

I want to remove the header on top of my activity. I tried this two ways, they work, but not at the 8th level.

1:

<style name="NOtitleTheme" parent="Theme.AppCompat.Light"> <item name="android:windowFullscreen">true</item> <item name="android:windowNoTitle">true</item> </style> 

2:

 this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

any idea why this is not working on api 8 ?

as soon as I managed to remove it in api 8 , but I donโ€™t remember how.


EDIT:

Solved! the problem was this.requestWindowFeature(Window.FEATURE_NO_TITLE) does not work in API 8, and <item name="android:windowNoTitle">true</item> does not work, but actionBar.hide() works, the reason getSupportActionBar ( ) returns null, one of two options before, I just forgot to delete both. when I delete one, I add another (which is stupid!) Thanks everyone! (sorry for bad english)

+6
source share
5 answers

Add to your manifest:

for full screen mode:

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

or (hide title only)

  <activity android:name="youtpackagename.activityname" android:theme="@android:style/Theme.NoTitleBar" > 

or use the code below to setContentView .

  this.requestWindowFeature(Window.FEATURE_NO_TITLE); 

or

 { ActionBar actionBar = getActionBar(); or getSupportActionBar(); actionBar.hide(); } 

Edit:

 final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); 

Its working fine below api 8 also .. I hope this helps you

+7
source
  <resources> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" parent="Theme.AppCompat.Light"> <!-- Theme customizations available in newer API levels can go in res/values-vXX/styles.xml, while customizations related to backward-compatibility can go here. --> </style> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> <!-- All customizations that are NOT specific to a particular API-level can go here. --> <item name="android:windowFullscreen">true</item> <!-- Hides the status bar --> </style> </resources> 

add this to your xml styles in your AppTheme.

AND

 import android.support.v7.app.ActionBarActivity; import android.os.Bundle; public class MainActivity extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getSupportActionBar().hide(); } } 

Add this to your activity. Use ActionBarActivity instead of Activity.

+3
source
  this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_main); 

use the requestWindowFeature method before the setContentView method.

0
source

Your โ€œworkaroundโ€ (hiding the ActionBar itself) is the usual way. But google recommends always hiding the action bar when the title bar is hidden. Have a look here: https://developer.android.com/training/system-ui/status.html

If your build version is less than 16, use it below

 public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // If the Android version is lower than Jellybean, use this call to hide // the status bar. if (Build.VERSION.SDK_INT < 16) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } setContentView(R.layout.activity_main); } ... 

}

0
source

For me, the only way that worked was this:

 <style name="AppTheme" parent="Theme.AppCompat.NoActionBar"> 

Just saying that my topic was the daughter of NoActionBar, I was able to eliminate the actionBar. All other paths failed. I do not know why.

0
source

Source: https://habr.com/ru/post/973314/


All Articles