Android Theme.NoTitleBar not working

I have facebook, for example, a sliding menu bar in my application in which two contents and the main layout of the application are handled by a special layout class.

I want to remove the title bar of my application

Question:

Even if I put

Android: Theme.Light.NoTitleBar

there is an empty header space in my manifest. Because of which, my whole layout is pushed down.

I tried using

requestWindowFeature (Window.FEATURE_NO_TITLE);

and

GetWindow () setFlags (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN) ;.

but still the header space is not deleted.

It looks like an application

enter image description here

enter image description here

I think this is caused by the special LinearLayout class, which contains the main sliding layout. But I cannot remove the header space from the custom layout class. Suggest a better solution.

Custom layout class

public class MainLayout extends LinearLayout { public MainLayout(Context context, AttributeSet attrs) { super(context, attrs); } public MainLayout(Context context) { super(context); } // Overriding LinearLayout core methods // layout based on the children @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); mainLayoutWidth = MeasureSpec.getSize(widthMeasureSpec); menuRightMargin = mainLayoutWidth * 10 / 100; } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); menu = this.getChildAt(0); content = this.getChildAt(1); content.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return MainLayout.this.onContentTouch(v, event); } }); @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if(changed) { LayoutParams contentLayoutParams = (LayoutParams)content.getLayoutParams(); contentLayoutParams.height = this.getHeight(); contentLayoutParams.width = this.getWidth(); LayoutParams menuLayoutParams = (LayoutParams)menu.getLayoutParams(); menuLayoutParams.width = this.getWidth() - menuRightMargin; } menu.layout(left, top, right - menuRightMargin, bottom); content.layout(left + contentXOffset, top, right + contentXOffset, bottom); } } 
+1
android android-layout titlebar android-theme
source share
7 answers

Finally, I was able to remove the header space. As it turned out, including this tag

 android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" 

in the application in the manifest, made the application full-screen and fixed the problem. But I wanted the status bar to appear in my application. Therefore, I had to compromise the status bar in versions of Android in which the header space was not reduced, and let it be the same in other versions. So, here is how I resolved it.

in the manifest, I saved the code as it is

 android:theme="@android:style/Theme.Light.NoTitleBar" 

to remove the title bar in the application

and in the action that used the custom line layout, I checked the version of Android and kept the full-screen mode of the application on versions smaller and equal to Gingerbread.

 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } 
+3
source share

u can directly indicate in the activity manifest file

 <activity android:name=".MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"> 
+5
source share

Try this in the manifest file

 android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 
+1
source share

Add the android: theme property to your AndroidManifest.xml:

  <application android:theme="@android:style/Theme.NoTitleBar"> 
0
source share

Hope this can help you.

 this.requestWindowFeature(Window.FEATURE_NO_TITLE); // Remove notification bar this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
0
source share

It seems that Theme.NoTitleBar only works in relation to the entire application, and not to the activity itself. So put it in the application tag (in the manifest):

 <application android:theme="@android:style/Theme.NoTitleBar"> 

Then add any custom style that you have for each activity.

Hope this helps.

0
source share

In the value \ style.xml define the name and themes for example,

Then go to androidmainfest.xml add to the action, for example .. android: theme = "@ style / NoActionBar"

0
source share

All Articles