Last actionbar tab partly obscured or not shown onscreen - android

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.

Related

How to change size of tabs on Android action bar

So I have a really simple app (picture below). I am using tabs and the scrolling (via swipe or by clicking the tabs) but I was wondering if I could possible change the size of the tabs somewhat dynamically.
For instance, "Home" doesn't need to be as big as "Most Recent", and there is a 4th tab that you cannot see on the screen that would ideally be seen if the tabs were smaller.
How could I go about this? I Googled around but I could not find anything relevant that seemed to work.
You can use title strips instead of tabs to solve this problem pretty easily:
http://developer.android.com/training/implementing-navigation/lateral.html#PagerTitleStrip

Android ActionBarSherlock does not display custom view with setDisplayShowCustomEnabled

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+

Android tab layout issue

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).

How to stop ActionBar Tab navigation to display as a spinner when it gets too long?

i have an action bar with a Tab navigation. While running on 3.1 everything was fine, but once i installed the app on a 4.1 device the tabs where forced to be displayed as a spinner, wrecking my layout design.
Looks like the tabs are taking too much space (if i remove some of the fragments everyting looks ok again.
Is there a way to stop this behaviour and display the navigation as tabs again just as in android 3.1? Does anyone know?
thanks!
I found the answer here. Had to set the navigation mode AFTER adding the tabs.
First of, just to clarify: This is not a bug and it works as intended. Reference this discussion on the Google code forums.
However, I came to the solution that if you override:
<bool name="abs__action_bar_embed_tabs">false</bool> //for ActionBarSherlock
<bool name="android:action_bar_embed_tabs">false</bool> //for default ActionBar
You won't have a NAVIGATION_MODE_LIST in portrait mode. However you won't have embedded tabs and if you rotate your screen to landscape it won't work either.
By default you'll have embedded tabs and therefore a NAVIGATION_MODE_LIST on a screen with a width of >480dp.
This behavior occurs (I assume) because the embedded tabs are limited to the width of the ActionBar, so if you override the boolean value it'll have tabs in a separate row and it won't collapse. But unfortunately I can't explain myself why this does not work in landscape.
Sorry, but you can't stop this. This is a feature, not a bug, according to Google. See: http://code.google.com/p/android/issues/detail?id=24439
As I understand you should consider using a ViewPager + PagerTitleStrip if you have many tabs and want to make them scrollable all time.
Here is a quote from ttps://code.google.com/p/android/issues/detail?id=24439#c9:
If your UI contains many tabs to the point where you hit the scrolling
tabs or collapse-to-spinner case regularly, you might consider using a
PagerTitleStrip as an indicator rather than full tabs to present this
info in a less cluttered way. This can be especially useful if the set
of tabs displayed is under user control. Clickable tabs work best when
there is a small, bounded set such as in the YouTube app. Scrolling
tab strips lose one-touch access to any tab, their primary advantage
over a simple title strip. Examples of the PagerTitleStrip style can
be found in the Android Market and Google+ apps.
I would not recommend using tricks as nobody guarantee that tricks will works stable.
If you really want to still use tabs and stop it from collapsing to a spinner, it is technically possible using reflection IF you happen to be setting a customView for the tabs:
View v = <your custom tab view>;
Tab tab = actionBar.newTab().setCustomView(v);
do{
v = (View)v.getParent();
} while (v!=null && !v.getClass().getSimpleName().equalsIgnoreCase("ScrollingTabContainerView"));
if(v!=null) {
try {
Method allowCollapse = v.getClass().getDeclaredMethod("setAllowCollapse", new Class[] { Boolean.TYPE });
allowCollapse.setAccessible(true);
allowCollapse.invoke(v, new Object[]{ false });
} catch (Exception e) {
}
}
If there is not enough space, the tabs will scroll in the ActionBar. The Tabs and any Menu actionItems are given 1/2 the screen width so you can calculate if the tabs will end up scrolling or not and make adjustments to tabs, menu actionItem labels etc or force the tabs into a stacked mode to avoid the scrolling tabs... OR as previously suggested, using the PagerTitleStrip instead.

Android Honeycomb - Tab

Previously I wanted to use Tabs on top of the page using TabActivity.
As I am working with Honeycomb I used Action Bar Tabs. That worked best for me.
Now, I want to use tab to on Login page, so that user can Log in two diff ways. For this, I thought I will put Tabs at the top of Login layout (center of the page and not top of the page).
Can I do that ? How?
you can have a tabhost with multiple views and even multiple activities in each tab.
Here is a tutorial : http://joshclemm.com/blog/?p=59
The tab host doesn't have to occupy the whole screen you can have something else on top, I sometime put a textview with the title.

Categories

Resources