Center selected tab in SlidingTabLayout/SlidingTabStrip - android

I am using the SlidingTabLayout.java and SlidingTabStrip.java classes to implement a tab navigation inside my app like described here.
Everything works fine and I really love this two classes. But I would like to center the selected tab (whether navigated through slide or click on the tab) to be in the middle of tab navigation. Right now it is always on the left side (except when you reach the end of the tab navigation than it is right). Also when you click on a tab the navigation scrolls back to the current tab and scrolls then to the tab you just selected. Is there anyway to stop this scrolling and just to center the clicked tab?
Using the method
slidingTabLayout.setDistributeEvenly(true);
does not do the trick.
I tried to read through the code and find a good starting point but I did not succeed. Does anyone know how to achieve that? Any good advice is highly appreciated.

Related

How to set the start default fragment of Bottom Navigation Bar to the center/middle fragment?

I am implementing the following GitHub repo in my project.
https://github.com/jaisonfdo/BottomNavigation I didn't paste my code here because I have other features in my project which are not important to the question. This repo is implementing a bottom navigation bar along pageViewer so that we can change the fragments with swipe left/right.
Now the issue is, I want the default/initial screen to be the middle tab and the 2nd fragment. I tried changing the "android:checked" of the second tab to be "true", still at the start, I am getting the 1st tab as default. I also tried changing the order in which the fragments are added initially but still, I am getting the first one as default. The picture is attached below. I want the "CHATS" to be displayed as pink and show the "ChatsFragment" in place of "ContactsFragments".
I want it in middle due to the UI requirements. Any help would be highly appreciated.
1
[]
I see the code at git repo you just need to set the viewpager item. try this code on setupViewPager() method after setting viewpager adapter
viewPager.setCurrentItem(1);

How to Create ViewPager with invisible tab bar

I'm not sure a ViewPager is the way to go, but it might.
My goal is to create an App with 3 screens.
A main screen and 2 other screens the are reachable by swiping left and right from the main screen.
i would like to have the screens as Fragments.
I have used a ViewPager, but I would like to get rid of the TabBar, and just stay with the swipe.
I managed to get rid of the Tabs, but the bar remains empty. I want it to be hidden.
Is that possible?
Is there a better way to do it ?
If this question was already answered, I have failed to find it and will appreciate redirection as well.
Thanks a lot,
Giora.
In your AnsroidStudio layout screen, go to the "Design" tab. Click on the theme option and select a theme with "NoActionBar.FullScreen" AFAIK ViewPager does not have any TabBar by default.

Adding a custom image onto a Navigation Drawer's center

I'm experimenting for the first time with Android's Navigation Drawer. I think it is a very elegant way to provide an application menu. However, showing my prototype to some friends, it seems that it is not quit intuitive to search for a menu i) on the top left corner respectively ii) on the left side of the screen.
To provide a "user hint" for case i), I added a custom image by creating an ActionBarDrawerToggle. This results in following design of the title bar (the little arrow is the cutom image, while the red star is the application icon):
Now while developping, I thought this is quite obvious, but apparantly I'm wrong :). So as a second idea, to support a user to find option ii) described below, I tried to figure out how to add a further image at a specific place, which I want to explain with following image:
Don't look at the design itself in the first place, but following: the image must be placed outside of the "view bounds" (when the navigation menu is hidden), and also exceed the navigation panel itself on the right side (always). Is this in any way possible without customize the entire navigation panel? I really wonder why I can't find much about this idea, since I think it is a very nice option to provide for the user (as long as the arrow don't disturbs the application usage)
Although I haven't actually tested it with Android's Navigation Drawer,
did you try putting an imageview in your activity's layout? The image would be placed in the middle vertically and on parent left horizontally. I believe this would work (i.e. the image will get pushed when you open the drawer. As an improvement you could also change the image itself in the drawer's callbacks, so that you have an arrow pointing right when the drawer is closed and an arrow pointing left when the drawer is open.
Hope it helps.

ActionbarSherlock Sliding Menu with Tabs scroll issue

I am using Sliding Menu and ActionBarSherlock in my application. Since I need to support old APIs so I cannot use the normal action bar.
I have multiple tabs (4-5) on the home page and also the sliding menu library works good. The issue I am facing is related to 2.3+ Android , when I click on any tab of home page and try to slide the tabs it works first time, but once you have scrolled to reach to last tab or any other tab then it is not easy to scroll back to the first tab. Instead the library slides the page and does not slide the tab.
One my Nexus 4 it works without any issues and is very smooth but when I use it on my device with 2.3.5 it is erratic.
Any pointers to this issue would be of great help.
Thanks.
I have encountered this a few times also. The best solution I have seen/used is to change the touch mode of the sliding menu based on the tab being displayed i.e.
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
or
getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
when you're away from the first tab. I suggest using TOUCHMODE_MARGIN so that the menu can still be opened. Then, when the first tab is reached you can switch the touch mode back to TOUCHMODE_FULLSCREEN. An Alternative is to keep the touch mode always as TOUCHMODE_MARGIN.
I hope this is of some help.

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