Android how to hide status bar without ActionBar - android

is it possible to hide status bar:
And show action bar without it?

try this..
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

Another way .In your manifest xml, at application level set this:
<activity
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" />
I hope it will works

Related

Unwanted Title bar android

I want to remove this unwanted title bar
I cant remove this
i have tried
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
This is not a title bar. This is ActionBar or Toolbar. You should extend your application theme from Theme.AppCompat.NoActionBar. Or just add android:theme="#style/Theme.AppCompat.NoActionBar" to <application/> tag in AndroidManifest.xml
add the following to your manifest:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
That should sort it, replace Theme with your actual theme if required, this line goes within the application part of the manifest or can go where the activity is declared.
You need to set your content view AFTER you have written the two lines
//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.layout_name);

Another way of hiding title bar

I am using this code for hiding the title bar. Is there any other way of doing the same?
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
You can modify your manifest to use a theme that doesn't use a titlebar
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen">
or you can specify a new style as done in this answer:
For Api level 14 and above you can use
getActionBar().hide();
else for below api if you have to add v7 support library change Activity to ActionBarActivity
then you can just call
getSupportActionBar().hide();
This will give you full screen with notification bar

Hide the status bar,but my view does not go to the top

I use
mContext.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mContext.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
mContext.getWindow().getDecorView().requestLayout();
to hide the status bar after setContentView.
The status bar is hided,but my view does not go to the top.There is a black rectangle
instead of the status bar.
You can use this in the Manifest file of that particular activity. remove above code from java file and put below code in Manifest in the activity
android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen"
here is the solution : just check it out
// hide titlebar of application
// must be before setting the layout
requestWindowFeature(Window.FEATURE_NO_TITLE);
// hide statusbar of Android
// could also be done later
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
For hiding the status bar please add request feture with no title and flag as full screen then
add the content view.
Code is
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_test);
And for only the notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

Android: How to set icon in title bar of Dialog activity?

I declared a dialog activity in my Manifest as follows:
<activity android:name=".myDialog"
android:label="#string/title_dlg"
android:icon="#android:drawable/ic_dialog_alert"
android:exported="false"
android:excludeFromRecents="true"
android:theme="#android:style/Theme.Dialog">
However, only the title's text appears in the title bar and the icon appears to be ignored.
Is there a way to also show the icon in the title bar?
Use this after your super.onCreate(savedInstanceState); call:
requestWindowFeature(Window.FEATURE_LEFT_ICON);
Then, set your contentView(R.layout.youLayout);
and then use this:
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);
The order is important.
I think using below line after super call will work
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
Keep in mind to place it before setting content view

Spinner click dropdown show status bar

I am using spinner in my applicaltion. In my app Android title bar and notification bar is hidden.
But when i click on the spinner the hidden notification bar is visible for a fraction of a second. Here is my code:
Main.java:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide the Title Bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Hide the Notification or Status Bar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.myActivity);
main.xml:
<activity android:name=".YourClassName"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"/>
}
But still i cant solve this problem.. If anyone has any solution please let me know.
If you are using tablet resolution then it will not work.
Try putting
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
in the application like this
<application android:icon="#drawable/icon" android:theme="#android:style/Theme.NoTitleBar.Fullscreen" android:label="#string/app_name">
thanks

Categories

Resources