TabLayout and bottom navigation - android

Hello, I have searched possible ways of implementing something like what can be seen in the image above, but couldn't find any help. I want to create a TabLayout and bottom navigation, such that the TabLayout is bound to the first bottom icon, and the second bottom icon is bound to another TabLayout.
I will be glad if you can help with examples or sample code. I am still more of a beginner.

As a beginner, you need to have a mindset that a problem can be split to more simpler problems by applying Divide and conquer algorithm.
For your case, you need to split the problem of TabLayout and bottom navigation. The problem after split are:
TabLayout
ViewPager
Combining TabLayout with ViewPager
Bottom Navigation
Combining TabLayout with ViewPager and Bottom Navigation.
First, you need to make a working TabLayout. Visit TabLayout. Then learn about ViewPager: Using ViewPager for Screen Slides and ViewPager. Then combine them.
Then you need to learn about Bottom Navigation at Bottom Navigation Views
After that you need to find how to integrate the Bottom Navigation with TabLayout and ViewPager.
Sample project with tab:
https://github.com/eure/citrus
Plaid should be interesting for you.

Related

Difference between Tab Layout and ViewPager?

I'm learning about tab layout because I need to use tab layout.
When i search for tab layout on Google, the one that comes up together is the view pager.
By the way, I'm not sure about the difference between tablayout and viewpager.
The tab layout has a menu at the top and screen switching is possible.
Although the view pager does not have tabs, it is possible to slide the screen just like the tab layout.
But why use the two together?
What's different?
Isn't it possible to slide in tab layout as well?
Yes, you can use TabLayout without viewPager. But without viewpager you won't be able to slide your page. You have to handle tabselect listener manually using this method then you have to click on the tab to navigate.
addOnTabSelectedListener(OnTabSelectedListener)
Likewise, you can use only Viewpager then you will be able to slide or swipe your page without any tabs.
From official doc
TabLayout
TabLayout provides a horizontal layout to display tabs.
Viewpager
Layout manager that allows the user to flip left and right through pages of data.
So Tablayout and viewpager are two different things but you can have the privilege of both tabs and slide only by combining them.
You can check here for tablaout without viewPager
TabLayout without using ViewPager

Nested tabs with viewpager swiping in android?

I've implemented nested tabs with view pager with no problems, but my problem is on the swiping part,
When I do the swiping action the main activity tabs will be switched, but I want the fragment to swipe instead. how can I achieve this?
I've tried implement main tab with tab host and fragment tabhost which doesn't have swiping feature at all, but that disabled whole swipe on the main and fragment together.
Instead of custom library you can try to use Bottom navigation view for bottom bar which has been added to version 25 of the Design Support Library. Here is an Article about it.
So android.support.design.widget.BottomNavigationViewin your activity together with android.support.design.widget.TabLayout and ViewPagerin fragment should work the way you want it to work. And this will also provide good UX (similar to one implemented in Google Plus App)
hello shaheen zahedi maybe it's possible please..with..below
just set bottom tab changed listener
like..
btnTab.setTabChangeListener(null);
You can disable view pager swiping on a particular ViewPager.
But I would suggest to not make 2 ViewPagers on the same screen.
Your bottom TabLayout and corresponding ViewPager can be replaced with BottomBar library.
I feel like it is wise to follow the Google Material guidelines. Not sure if you checked it out already...
Either way, here is what Google considers best practice for lateral navigation between tabs. Hope it helps!
I made a sample project with nested tab and fragment. may be it might help what is you looking for.
following link to download:
NestedTabWithFragment

Tablayout & viewpager scale and translate

I have Tablayout and Viewpager on the main Android activity. Its size is about half of the screen. In one of the Tab page having a listview (extends ListFragment)
Is there any way to resize and translate the Tablayout and Viewpager while scrolling the listview.
you can do this with parallax effect. see the link below to have this kind of implemetation.
Parrallax effect link
check this example. I hope it help.
Effect using coordinatorlayout

How to implement a horizontal scroll / swipe between Fragments?

I would like to achieve a navigation in my app like Pinterest or Trello, that is, kind of three tabs to navigation + horizontal scrolling.
I have made a custom tabbar for this (since I couldn't guess how to change tabs width in my actionbar with navigation TAB mode). So I have three buttons to navigate from one fragment to another. Now I would like to implement the horizontal scrolling like these two examples, to also navigate among my fragments.
I have read about View Pager but I don't know if it fits to my case, since I don't have only views but fragments. Does anybody have an example or an idea of how to do it? Could I apply it among different activities?
Thanks
Please take a look at the duplicate question that I just answered:
How to implement a swipe-gesture between Fragments?
I suppose the Android ViewPager is what you are looking for:
http://developer.android.com/reference/android/support/v4/view/ViewPager.html
Here is a nice tutorial on how to implement it:
http://developer.android.com/training/animation/screen-slide.html
The basic idea is that you have multiple Fragments, each representing
a different Screen. The ViewPager enables the user to swipe between
the different Fragments and display different content.
You can use ViewPager. More information about viewpager this.

Scrolling tabs instead of fixed tabs in ActionBar

Is it possible to make tabs in ActionBar look like scrolling tabs, e.g.:
Because all I can get are fixed tabs like:
What you're trying to achieve are not scrolling tabs, but a ViewPager. You won't be able to get the look you want using only tabs.
Take a look at the good tutorial here on the ViewPager: http://android-developers.blogspot.co.uk/2011/08/horizontal-view-swiping-with-viewpager.html
The best way to implement this is to use Fragments, and the library ViewPageIndicator for the top list of pages.
Please check: http://developer.android.com/training/implementing-navigation/lateral.html#swipe-tabs

Categories

Resources