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
Related
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
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.
When using a ViewPager, is there any advantage to using TabLayout instead of PagerTabStrip or vice versa? Or are they equivalent? Is one more convenient than the other? Does one offer greater functionality? Again all questions are asked, and thus all answers are expected, in the context of ViewPager. Thanks.
TabLayout is a material concept that replaced the deprecated ActionBar tabs in Android 5.0.
It extends HorizontalScrollView, so you can keep adding tabs horizontally which can include text, icons, or custom views and scroll through them linearly without paging.
TabLayout provides the setupWithViewPager(ViewPager viewPager) method to attach to a ViewPager instead of being part of the ViewPager like the PagerTabStrip.
A PagerTabStrip is more of an indictor for the current page of a ViewPager, and "it is intended to be used as a child view of a ViewPager widget". The scrolling for it does not act like the TabLayout since each tab is part of the page instead of individually horizontally scrollable.
I have an activity layout in which I have a viewpager that contains a couple of fragments. One of the fragment holds a listview (image sample attached).
What I'm trying to do is to scroll the listview and stick the TabStrip to the top of the layout, so when you are scrolling the list, the viewpager's fragment titles are always visible but you can see the entire listview content.
Above the viewpager there are views that needs to scroll up when the listview is scrolling.
Is any way to achieve this?
I've tried with scrollview and placing the viewpager inside it, but it doesn't work because the viewpager doesn't display at all.
Please help!
i've found the solution by using this nice library from github!!!
noties/Scrollable
I'm using a actionbar with Window.FEATURE_ACTION_BAR_OVERLAY and some transparency. Additionally I'm using a ViewPager with a PagerTabStrip. The problem is the PagerTabStrip is now displayed underneath the actionbar.
Applying a margin to the PagerTabStrip doesn't work at all and applying a margin to the whole ViewPager prevents the content (A ScrollView inside a Fragment) to scroll underneath the actionbar and the PagerTabStrip, which should be semitransparent too.
So currently I'm stucked with
which isn't ideal at all :D
Anyone got an idea to implement this behaviour?
Edit: so the problem consists of 2 parts. Making the content scroll underneath the PagerTabStrip and moving the PagerTitleStrip.
Add a view above the pager tab strip with a height of
?android:attr/actionBarSize
It will take the height of the action bar and "push" the content down.