Android: Problems with splitActionBarWhenNarrow - android

I am trying to use the ui option: splitActionBarWhenNarrow in my application, but it seems as I am experiencing an unwanted behaviour.
EDIT: Attaching a small gist with some more code.
This is the code in the manifest for the activity:
<activity
android:name="com.example.HomeActivity"
android:uiOptions="splitActionBarWhenNarrow"
android:label="#string/app_name" >
That is the only activity I intent to change the ActionBar style on. In the activity code, I have disabled the actionBar title and icon, so the tabs can merge as the only top action bar.
private void setupActionBar() {
final ActionBar mActionBar = getActionBar();
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mActionBar.setDisplayShowHomeEnabled(false);
mActionBar.setDisplayShowTitleEnabled(false);
mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_one).setTabListener(this));
mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_two).setTabListener(this));
mActionBar.addTab(mActionBar.newTab().setIcon(R.drawable.tab_three).setTabListener(this));
}
This worked well; however, it seems as if the bottom action bar is not going all the way to the bottom of the activity, but rather just below the top action bar.
Here is what it looks like after the code I wrote, How can I get it to go all the way down, like for instance on the Android's stock messaging app?
Edit, reattaching images.
Here's how it currently look with the code above, and here's how I want it to look.

I have posted a working demo app with tabs and an actiobar at the buttom
Here
Check it out and hope it helps

Related

how to hide the status bar from all layouts?

I want to hide the statusbar from all layouts on click of button.That button i have define in setting layout. But on click of hide button the status bar of current layout is getting hide but on other layout is unaffected.So let me know how to implement it on all the layouts of mu app.
Create a superclass for all Activities, call it something like BaseActivity or AbstractActivity and make each activity extend this class
In the onCreate, before setContentView, read from a database like SharedPreferences whether the status bar should be hidden. If so, then hide it.
In your Settings activity, call recreate() so that each onCreate from the previous activities are called again.
It actually depends on the version of android you are using. For example in Android 4.0 and lower you can achieve it by doing:
<application
...
android:theme="#android:style/Theme.Holo.NoActionBar.Fullscreen" >
...
</application>
For full documentation go to: https://developer.android.com/training/system-ui/status
Edit: What would be better for your button is this code:
void HideStatusBar() {
View decorView = getWindow().getDecorView();
// Hide the status bar.
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
// Remember that you should never show the action bar if the
// status bar is hidden, so hide that too if necessary.
ActionBar actionBar = getActionBar();
actionBar.hide();
}
So, when the user clicks the button call this function. Remember this also hides the action bar or toolbar, so if you don't want that remove the actionbar.hide() part. It's nice, but unfortunately, it only works on Android 4.1 and higher, so if you are supporting lower versions too better look at the documentation for clues. Hope it helps!

android: title bar hide

I have this activity made with actionBarSherlock. Is it possible to hide title of activity (not only text but the title bar) I tried:
getSupportActionBar().hide();
but it hides tabs too.
Picture:
https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-prn1/q71/1017267_10200157522600680_915484448_n.jpg
1.You must call setNavigationMode(NAVIGATION_MODE_TABS) to make the tabs visible
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
2.You must disable the activity title by calling setDisplayShowTitleEnabled(false)
getSupportActionBar().setDisplayShowTitleEnabled(false);
3.You must disable application home affordance by calling setDisplayShowHomeEnabled(false)
getSupportActionBar().setDisplayShowHomeEnabled(false);
This way should able to able to get a look like this in your activity.
try one of these possibly?
add this to the manifest file under application:
android:theme="#android:style/Theme.NoTitleBar"
or in your activity:
ActionBar actionBar = getActionBar();
actionBar.hide();
getActionBar().setDisplayOptions(Window.FEATURE_NO_TITLE);
It worked for me hope it will help you out.
And this will give result like this

Android: Sliding Menu Slide only content

I'm using Sliding Menu with ActionBarSherlock in my application. The actionbar and sliding menu works fine, but i want the sliding menu to slide only the content and not the actionbar like the latest version of youtube application.
Is this possible with slidingmenu? If yes, please tell how
Thanks in advance
Below is my code for actionbar and slidingmenu
getSlidingMenu().setSlidingEnabled(true);
getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
getSlidingMenu().setShadowDrawable(R.drawable.shadow);
getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
getSlidingMenu().setBehindScrollScale(0.25f);
getSlidingMenu().setFadeDegree(0.35f);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
Solution:
setSlidingActionBarEnabled(false);
Reference:
Have a look at example
your final code will look something like this after adding the suggested solution,
getSlidingMenu().setSlidingEnabled(true);
getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
getSlidingMenu().setShadowDrawable(R.drawable.shadow);
getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
getSlidingMenu().setBehindScrollScale(0.25f);
getSlidingMenu().setFadeDegree(0.35f);
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
setSlidingActionBarEnabled(false);
I hope it will be helpful !!
According to the developer on GitHub:
Look at step 1. You have 2 options, SlidingMenu.SLIDING_WINDOW or SlidingMenu.SLIDING_CONTENT.
SLIDING_WINDOW will include the Title/ActionBar in the content section
of the SlidingMenu, while SLIDING_CONTENT does not.
I tried with the solution given . But it does not work.
I am using SherlockActionBar and SlidingMenu together.
It works good when I am not setting anything for setSlidingActionBarEnabled method. But it slides the whole window , I want to make it slide only when content is swiped.
So I called this method : setSlidingActionBarEnabled(false);
This has couple of issues :
This makes the app show a blank white page when it is loaded first. I have multiple tabs shown in action bar , so the first tab is shown as selected but the content is empty.
If I slide when say I am in tab 2 , then the back page (or behind page) content is visible but it also overlaps with what is shown currently on tab2.
Any pointers would be helpful.

Hide App name and it's bar

I've been trying to remove this bar (cant hotlink images, yet, check next link):
http://i.imgur.com/fRvMW.png
But I can't achieve it.
Tried the following:
Added into manifest the following:
android:theme="#android:style/Theme.NoActionBar"
But resulted as crash. Probably because I don't have this "Theme". I can't find out what should I write here.
Also tried to remove manually on each Fragment by Graphical Layout, selecting "No action bar", and it doesn't show up on the "preview" but it's shown in the app, probably because its the wrong place to configure it.
Note that it's with fragments. I searched about doing it by code, but I just found options to do it for activities.
So, my question is: How can I hide the App Action bar?
Edit:
SOLVED
On my code, I've this:
final ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
So, just added:
bar.hide();
And everything is working. Even if the tabs names aren't shown, the navigation still works (Swaping right and left for swapping fragments.)
Have you tried this?
ActionBar actionBar = getActionBar();
actionBar.hide();

ActionBarSherlock Actionbar Customization ?

I want to remove the back icon and the application icon from the Actionbar. I am using ActionBarSherlock. I have seen many applications that dont show an application icon or a back button ? Is this the best implementation ?
Kind Regards,
I think by "back" button you mean up button that is used to navigate up the application's structural hierarchy. Anyway hope this piece of code solves your problem if you don't want to keep the app icon on top.
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true); // if you want to show title on Actionbar
the action bar doesn't have a back button since all android devices should include a back button in some way or another.
what you probably mean is the up button , which should go to the "home page" of the app.
you don't have to use it . it's just a nice thing to have. use setDisplayHomeAsUpEnabled for showing and hiding it .

Categories

Resources