Android status bar stays - java

In my onCreate() method, I use this code to remove the status bar:
// Remove the status bar from the top
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
Yet when I start up the app, I can still see the status bar for like a second. How can I prevent this?

Add the following attribute to the activity in the manifest:
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"

you must use requestWindowFeature before setting the content view

Related

Create a Custom Toolbar programmatically on Android

I have an app with some behavior. As an upgrade I'm going to add a Toolbar to the app. I know, I can do it putting de XML on each activity. But I want to create a Layout XML for the action Bar and inflate on each activity on the OnCreate method.
This way I think I can add the bar whenever I need it without touching the XML,and maybe make the code more efficient:
Assumptions:
I have a XML with a layout with tag "< Toolbar >"
The app has the noActionBar theme
This is an extract of OnCreate()
android.support.v7.widget.Toolbar barra =(android.support.v7.widget.Toolbar) getLayoutInflater().inflate(R.layout.barra_herramientas,null);
LinearLayout layout_actividad = (LinearLayout) findViewById(R.id.contenedor_principal);
layout_actividad.addView(barra);

Hide Action bar In a fragment

I'd like to hide the Action Bar of my Fragment.
I searched on Google for 1-2h. But I didn't find any proper anwser...
So if you could help me that would be nice.
You can try using getActivity().getActionBar().hide();
It is called ActionBar You can hide Action Bar using getSupportActionBar().hide();

Actionabar issues coming from full screen

I got a full screen activity that leads to an activity with an action bar. When the scond activity loads, the actionbar is half hidden by the title menu.
Why is this happening and what can I do to prevent it?
EDIT: as seen below, the title bar hides some of the action bar.
1 ) You have to keep same theme for all activity ,put actionbar activity them in application tag in manifest file
2) If you want to use full screen activity then getSupportActionBar().hide(); If you have Simle activity and Actionbar activity then while launching simple Actionbar activity to Simple activity creates problem.
check your activity deceleration in the manifest file. Declarer your activity like this.
<activity
android:name="com.android.MainActivity"
android:theme="#android:style/Theme.Light.NoTitleBar">
</activity>

How to DISABLE status bar in Android?

I want to disable status bar in my application.
link
with:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
I still can activate status bar with fast swipe from top to bottom screen.
Is possible to fully deactivate it?
What API version are you using? Anyway in the dedicated android developers page (Hiding the Status Bar) there is a detailed explanation on how to do it with additional clarification for API<16. In particular if the status bar should always remain hidden in your app you should set the activity theme in your app's manifest file as follows:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>

How to set dynamic created action bar to bottom?

To create a navigation bar, I have dynamically create an action bar:
public void onCreate(Bundle savedInstanceState) {
ActionBar actionBar = getActionBar();
}
And add tabs one by one:
// Create first Tab
tab = actionBar.newTab().setTabListener(new FragmentsTab1());
// Create your own custom icon
tab.setIcon(R.drawable.tab1_hdpi);
actionBar.addTab(tab);
The problem is , the action bar is at the top by default. How can I placed it at the bottom? I found layout_below may be suitable for this case . However , as it generates dynamically, how can I know its ID? Thanks a lot.
Edited:
After adding split option, it doesn't make any changes, is it due to my action bar is dynamically generated?
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:uiOptions="splitActionBarWhenNarrow"
package="com.example.tabtest"
android:versionCode="1"
android:versionName="1.0" >
And
<activity
android:name="com.example.tabtest.MainActivity"
android:uiOptions="splitActionBarWhenNarrow"
android:label="#string/app_name" >
Add this to your activity tag in the Minifest
uiOptions="splitActionBarWhenNarrow"
You haven't really answered the OP's question.. I'm searching for an answer as well since it looks like the custom bar always gets placed top and default menu bar on bottom if I use this code to bring the custom view:
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowHomeEnabled(false);
// displaying custom ActionBar
View mActionBarView = getLayoutInflater().inflate(R.layout.custom,
null);
actionBar.setCustomView(mActionBarView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
:(
With Android 5.0 API, uiOptions="splitActionBarWhenNarrow" is deprecated. Unfortunately, this is not very well documented as yet. For details, you can read up this article.
http://commonsware.com/blog/2014/11/18/android-5p0-deprecation-splitactionbarwhennarrow.html

Categories

Resources