I have a tab in the middle of a page, the tab is inside a listView, to render the the tab I had to set a fixed height on it, but the problem is that the content of the tab it will vary, it can have 1 or more items, how can I make the tab height dynamic?
I've answered at in the similar question.
https://stackoverflow.com/a/57558695/5541523
Maybe it could help you.
P.s. You will need to add GestureDetector if you want to change tabs on swipe.
Related
I am working on a little dictionary app which currently looks like this:
I want the start of the first tab title and the end of the last tab title to be aligned with the start of péngyou and the end of HSK 1.
I tried using custom layouts for the first and last tab aligning the text left and right and using the correct padding, but that leaves me with two problems.
The distribution of the tab titles looks off. I guess tabs originally have equal width and the titles are centered in their respective tab. Do I have to calculate the positioning for the remaining tab titles myself? How could I achieve that
I use tabIndicatorFullWidth="false", but the tab indicator gets centered in the tab instead of being aligned with the title. Do I have to overwrite the tab indicator behavior? If yes, where would I do that and how could I achieve alignment regardless of where the title is aligned in the tab?
Did I miss an easy solution to this problem?
I managed to solve my problem by using tabMode="scrollable" and a custom TabLayout. In the onMeasure function of the TabLayout I calculatted the width each tab should have and added paddings accordingly.
I Would like to achieve the following
I was able to use the following library
https://github.com/Hongchae/CoverFlowPager
and after some customization i was able to have this
Now i want to adjust the pages to appear like the first image
Appreciate your help ,Thanks in advance
For showing the preview of left and right fragments you have to set the following values:
// This for avoiding the truncate effect
viewpager.setClipToPadding(false);
// This for setting the padding for seeing the other fragments
viewpager.setPadding(left,0,right,0);
To modify the space between the fragments in the viewpager use
viewpager.setPageMargin(int);
probably this post will help you ViewPager show next and before item preview on screen
I tried searching but can't seem to find a swipeable view that can only swipe only half.
Here is an example image.
I tried creating two pages (in a tab) that contains image 1 and image 2, but the animation is having two stars when you are in mid-swipe.
Cheers.
Edit: found a working example. I will just try mimicking this one.
https://github.com/baoyongzhang/SwipeMenuListView
You can use two ViewPager to serve for this purpose and customise them in a way so that one ViewPager change the other. In this way, I will give a feel that it is being swiped from half.
I have created PageTabStrip and ViewPager to show multiple list fragments. inside my app viewpager content has a specific width ( it doesn't occupy the whole screen ) partial pages are visible.
as my ViewPager content has specific width, my PageTabStrip are not aligned accordingly.
please see the image below , so how do i align the Division caption under first list and Item under second list ( second tab is getting out of the screen , see in red)
![enter image description here][1]
I think you misunderstand the concept of viewpager and PageTabStrip and misused them with your design requirement.
The viewpager is a widget that shows each page one at a time and when you swipe you can see the other pages. Other pages are all invisible until you swipe to them, then it shows you one at a time.
The pageTabStrip helps you to find that which page is currently displayed and what is the title of the next page and previous page if you swipe to those, so it just gives a hint about next and previous pages.
What your picture tells us is you have created a page and set its title Division,(as the pageTabStrip shows) and you have put all of your layouts inside it and you called the next page title ITEM but I think if you swipe to it, it is either empty or just duplicates current view. Your problem is here, if you put all your layouts inside one page you can not set different title for different part of current page, you only can set one title and this title applies to whole layout of current page.
Here is my different solutions to represent your layout:
1) Do not use pageTabStrip or give it a general title for example Search and provide a sub title for each part of current layout with for example linearlayout. It means add a linearlayout above the current page and divide it and put each subtitle in a correct position.
2) Use dual pan fragment design pattern and remove the viewpager.
3) Move search item type section to the next page.
I Have created an android app, which has view flipper and it has 4 child views
When I swipe from right to left it changes and moves on to next screen
, but I want something that indicates the current view like there are 3 to 4 dots in android homescreen, which represents the current view. Something similar or if there is any different way to show it would be helpful. Please help. Please let me know the code.
Thanks in Advance.
There is the ViewPagerIndicator created by Jake Wharton. It was built for a ViewPager (obviously), but you can use parts of it and adjust it to your view flipper.
you have to create a graphic first and than put that graphic to ur views through imageview.....go through the below link you'll get ur exact answer.......
Switching views in ViewFlipper