Android. Compose how to implement page by page scroll - android

I am new in compose and I'm trying to implement own ViewPager. I was create HorizontalPager and PagerState. Inside Pager I create LazyRow, and everything looks good but I have some problem. I want to make it scroll only one item at a time. but it doesn't work like that. As far as I understand it is responsible flingBehavior.
But unfortunately I don't quite understand how it works. I found an example in the library com.google.accompanist:accompanist-pager, but it is very difficult for me to understand, in addition, an additional library is used there (chrisbanes.github.io/snapper), is it possible to implement this in a simpler way?
Please, help me how to implement page by page scroll.
UPD: In this page https://fvilarino.medium.com/creating-a-viewpager-in-jetpack-compose-332d6a9181a5 I was found a simpler example, but scrolling on one page also does not work here, tell me please in which direction I need to move in order to perform a page by page scroll within this

Related

Firebase with viewpager

I am currently building an app using firebase.
I have an activity in which the background and UI are the same, but the page has only the contents that change inside according to the date.
It`s kind of some diary app.
I am worried about whether I need to ViewPager or not to use ViewPager, but if I have saved it somewhere and clicked on that date, I need to display the contents with setText(). I'm not sure about that how to do more optimization.
And when I scroll horizontally across the screen, I want to see the pages change with swipe-animation. Do I have to use viewPager? I mean I use one page but I want to give a fake animation effect as the page looks. If this helps optimally.
Anyway, So I'm looking for an example that uses viewPager with firebase recycler-view, but it's a bit hard to find. Is it better to use a fragment? with this?
Optimization has been troubling for weeks on issues.
I have a lot of questions, but I would like to hear good advice on these things.
I would appreciate it if you could explain it slowly and easily.
Thank you very much for reading.
Page has only the contents that change inside according to the date.It`s kind of some diary app. I am worried about whether I need to
ViewPager or not to use ViewPager?
Yes, Viewpager with FragmentStatePagerAdapter is a good choice here, as there may be many dates in your case with its own content.
Check out the below link, it explained very well how any why to use viewpager with tabLayout.
https://guides.codepath.com/android/google-play-style-tabs-using-tablayout
And when I scroll horizontally across the screen, I want to see the
pages change with swipe-animation. Do I have to use viewPager?
For animation between the page swipes, you can use pageTransformer.
Checkout this
https://developer.android.com/training/animation/screen-slide.html
and
https://medium.com/#BashaChris/the-android-viewpager-has-become-a-fairly-popular-component-among-android-apps-its-simple-6bca403b16d4

Xamarin Forms / Android ScrollView with Paging, same as UIScrollView.PagingEnabled

I want to create a scroll view with pages that can be scrolled vertically and horizontally as well.
The scroller should be just like a slideshow on a website, to slide between images (content). Something like ScrollView, but to stop at a certain point when scrolled.
I am using this in Xamarin.Forms, so I'll need to create a custom renderer (Android) and set the content of the pages from Forms.
I tried ViewPagers, but I want to be able to set the content from Forms page, not from predefined layouts...
I just couldn't find a clear example/tutorial so I can understand how to approach this problem. I also think about overriding some methods from ScrollViewRenderer class, to intercept and only slide to a certain point, but have no idea which methods and properties to change.
Something like CarouselPage on XF, which can be used inside a layout.
Any help or examples would really be appreciated. Thanks!
I'm searching for 2 days for a solution for this problem.

ListView or ScrollView?

At the moment, I am using a ScrollView with a LinearLayout inside it. I want to implement a snap function. Am I better off using a ListView? Is it even possible to implement a snap function with my current setup? I want to keep things simple.
By "snap function" I am assuming that you mean paging so the user can swipe from side to side similar to the Play Store or the ICS Dialer apps. While yes, you can implement this yourself with a ScrollView, or any number of other solutions, I don't think you should because you can use Android's ViewPager class.
ViewPager is a wonderful view that uses a collection of Fragments as pages in a single layout. This will give your user a very familiar and consistent interface, and will save you a lot of very difficult code.

Swipe Indication for user Android

Suppose I have a ListView displaying exactly 10 rows that is not intended to scroll.
When the user swipes, the next list of 10 rows would be displayed. The bottom of the ListView would say something like "page 2 of 3".
How can I indicate to users that they should swipe to get the next page?
A page indicator might be helpful like you said. I view-pager may be another option. In that case I would use: http://viewpagerindicator.com/
I think you are best off rolling your own solution using a ScrollView and/or a ViewPager
According to a GoogleIO presentation about ListViews, they are coded with many "behind-the-scenes" tricks in order to optimize performance.
When you start trying to modify how they work, then you end up with a complex widget that doesn't make use of its own complexity and optimizations.
Some type of vertical view pager could be good for what you see though.
Reference: http://www.youtube.com/watch?v=wDBM6wVEO70

Extending viewpager to include navigation indicators

I'm trying to add some arrows to the screen to indicate if there are items available to the left or right so that the user knows to scroll.
Initially I just added these images into the instantiateItem function in the pageradapter. However I want to animate the arrows so that they fade in and out and disappear when the user touches the screen.
I've started to think that I may be best off extending the viewpager class so that it always displays the arrows independently of the adapter. I've looked through the code but can't see a place where I would add the overlay view.
Has anyone got any ideas?
Thanks,
m
As suggested by CommonsWare
You might wish to take a look at github.com/JakeWharton/Android-ViewPagerIndicator and see how Jake did it.
this information lead me to the solution.

Categories

Resources