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();
Related
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>
i am new in android programming!
i want a full screen image like Hill Climb Racing (as you can see below)
i try to use
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
but it just disappear action bar and i want to disappear both action bar and android default key bar (home button, back and the another one)
If you are targeting android 4.0 and higher
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
Check this developer site for more detail information
try this in your activity on the manifest
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
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
To keep this simple: I have tabs in my actionbar, but the action bar take up too much space. I want that extra space. I need a way to hide the action bar, yet keep my tabs. Is there anyway to do this? Or is there a way I can get the tabs built into the action bar like it is in landscape mode? Thanks!
You can have an empty Actionbar, then the tabs will occupy the space:
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false);
Try the below code:
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
Also remove the below in code which is added default when project is created:
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
This did the trick for me
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
I also commented the line
getMenuInflater().inflate(R.menu.main, menu);
Ahmad's answer is correct but it requires API 11. For supporting lower APIs, use this code -
setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
To enable it, use -
setNavigationMode(ActionBar.NAVIGATION_MODE_TABS)
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