I'm working with ActionBarSherlock and have an app with several tabs. In one of the tabs I'm trying to display a SearchView using setDisplayShowCustomEnabled(true);
Since the search should only appear in one of the tabs, when this tab becomes visible, I'm calling setDisplayShowCustomEnabled(true); and when a different tab becomes visible, I'm calling setDisplayShowCustomEnabled(false); to hide the search.
This works well on Android 4+ (when the stock ActionBar is used), but does not work on older versions (when the replacement is being used)
After some digging around, it appears that in the rest of the tabs I'm showing a title. It seems that showing both a title and a custom view does not play well together - for some reason when you do this, both are hidden and you end up seeing nothing.
Fix:
When the search tab is visible:
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
and when a different tab is visible:
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayShowCustomEnabled(false);
So the solution was to hide the title accordingly.
This was only required in old Android versions, as it was working without the title part on Android 4+
Related
I am trying to hide action bar, but keep tabs.
I used following codes, but this is not working for Android KitKat (Tested on Nexus 5).
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
Does anyone know how to solve this issue out on Android KitKat?
ActionBar tabs are part of the ActionBar, you can't display the tabs without the ActionBar.
Instead, you have to use TabHost.
Perhaps you didn't yet try:
actionbar.hide()
I'm using the navigation tabs mode in an actionbar. The tabs are created dynamically along with the fragments which fill them.
My problem is shown in the screenshot below. The more tabs I have in the actionbar the more the last tab becomes obscured/covered. The last tab should read 10030. The tabs start at 10000, so there are only 30 of them. If there are only 10 tabs the view seems okay. At 20 the last character becomes covered, at 100 tabs the entire last tab plus some of the 99th is covered.
This is a FragmentActivity using a ViewPager and PagerAdapter. This is done using the native actionbar not ActionBarSherlock. I'm using a split actionbar also.
Has anyone else ever had this issue? Or anything similar?
This is running on a HTC One X on 4.0.3. I have replicated this issue on another phone (Huawei G300 Ascend) running 4.0.4. I have searched and found nothing related to this issue on this or any other site.
I'm having a bit of a problem with the Android tab layout. I've been trying to make a screen that holds 4 tabs, and a fragment beneath them, when a user presses each tab the fragment dynamically switches to another activity and the tabs stay static, my problem is that I tried to implement it with tab layout and it's deprecated in since Android 4.0, so I tried it with the action bar tabs but then I have the action bar that I don't want nor need.
I have two questions:
Is it possible to use action bar but to hide the action bar and show only the tabs?
Is there a way to use tab layout on Android 4.0 and higher versions?
1.Yes there is possibility.....you should try http://actionbarsherlock.com/
2.ActionBarSherlock works from sdk 7 to sdk 16
I am not really sure about whether you can achieve it or not but if you want to play around with the ActionBar, this would be one of the best places to start.
Just because it is deprecated, doesn't mean that you can't use tabs in Android 4+. ;)
You surely can use Tabs and TabLayout in Android 4+ and everything works perfectly(though you apparently should not as ActionBar is a must better option).
I have tried it myself because even I prefer the TabLayout more than the ActionBar, and thankfully haven't run into any issues until now!
The only thing you will notice is that Eclipse will draw a yellow line over the deprecated code (which you can obviously ignore or just choose to hide all deprecated warnings).
I'm trying to implement an application with a specific view. It needs to have a horizontal bar at the top that contains the app icon, and other buttons and spinners. These items must be static and should appear on every page of the app.
Below that horizontal bar will be a Tabbed component, with the tabs being horizontal at the bottom of the page. I can also implement the desired behavior with the tabs on top of the Tabbed component. Each tab will obviously change the fragment being displayed within the tab's frame.
I am working on an implementation that uses the ActionBar and the menu options. However, I can't get the menu options (my buttons and spinners) to appear above the tabs. And I'm not sure if menu options is the right approach. Any ideas?
Silly me! the answer was right there. I simply had to turn the title bar back on (only with no title) and the menu options would appear right into that title bar.
keep in mind that this feature is heavily dependent on the version of android and model of device that you have.
Older phones have a menu button which will bring up the same menu, as do some modern phones (like the galaxy SIII), so, be sure to test this everywhere so you know what the end-user will actually experience.
I'm having serious problems getting tabs in actionbarsherlock below main action bar tabs to work in an app that runs from Android 2.2 up and looks like Android 4. (see link)
Tabs position
Have you tried running the official Demos app of ActionBar Sherlock? (https://github.com/downloads/JakeWharton/ActionBarSherlock/ActionBarSherlock-Sample-Demos-4.2.0.apk) It should contain a demo for the actionbar with Tabs.
If that works on Android 2.2 then you know the problem is in your code and you can check the Demos source code to see what you are doing differently (https://github.com/JakeWharton/ActionBarSherlock/tree/master/samples).
It's usual behavior of action bar (actionbarsherlock just simulate it). Use
ActionBar act = getSupportActionBar();
act.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.mytab_base_t));
to avoid white color in top bar (this option you can't access from any theme item yet). You can also monitor action bar height to change custom view of tabs on-fly, but you can't change action bar behavior, forget it. Otherwise please use PagerTitleStrip against action bar tabs.