Android Theme.NoTitleBar doesnot work
android, android-layout, android-theme, titlebar
Solution
Finally I was able to remove the titlebar space. As it turns out, including this tag
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
on application in manifest made the app fullscreen and corrected the issue. But I wanted the status bar to be visible in my app. So I had to compromise the status bar on the android versions in which the titlebar space was not reduced and let it be same on other versions. So here is how I resolved it.
in Manifest, I kept the code as it is
android:theme="@android:style/Theme.Light.NoTitleBar"
to remove the titlebar in the app
and in the activity which used the custom linear layout I checked the android version and kept the app fullscreen on versions less than 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);
}
Problem
I am have a facebook like sliding menu bar in my app in which the two content and main layout of the app is handled by a Custom layout class. I want to remove the titlebar of my app Issue: Even though I place android:Theme.Light.NoTitleBar in my manifest there is a blank space of title bar. Due to which my whole layout is pushed downwards. I have tried using requestWindowFeature(Window.FEATURE_NO_TITLE); and getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); but still the titlebar space is not removed. This is how the app looks like I think this is caused due to the Custom LinearLayout class which holds the main sliding layout. But I am unable to remove the titlebar 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); } } ```