ListView or ScrollView? - android

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.

Related

Android. Compose how to implement page by page scroll

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

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.

Android view with many different layouts

I'm creating a home screen for an Android app. The homescreen will be a vertically scrolling list, containing many different elements.
These elements can be things such as a simple card list, a side scrolling carousel of items (ViewPager?) or just a basic WebView.
Is it possible to use a RecyclerView efficiently with multiple types of content (that can also have their own adapters). Or is there something else available that I may not be aware of?
The BBC news app is similar close to what I am trying to do.
A RecyclerView is actually designed to do such things, I don't think that you have any other choices right here, however this shouldn't cause you any problems I've tried something like this earlier last month and it worked perfectly for me
even tho i added multiple types of content, the only problem that i faced was with the ListView because i added some sort of animation to the content
but after i used a recyclerView everything worked fine but you also have to reconsider using a ViewPager inside a RecyclerView as an Item, it might cause you some problems as it should be used in conjunction with Fragment to allow users to flip left and right through pages of data which in most of the cases are tabs.
checkout the documentation.
And the BBC news app that you refer to in your question is using a RecyclerView inside a tab into a TabHost that uses ViewPager.
More Information About RecyclerView.
Good Example for RecyclerView Sample for RecyclerView

Alternative UI for Android ListView

Suppose I have a list of data to be displayed. I know how to display it using a ListView And it is very simple and easy to do it that way. But I am looking for an alternative way to achieve the same. I don't expect to have more than 20 items in the data set I am planning for.
I was thinking of a number of squares that the user can swipe to see the next one etc, similar to some widgets on home screen.
I came across android.widget.StackView, any advice available for this?
You can try StackView (http://developer.android.com/reference/android/widget/StackView.html).
This is how the Gallery and Youtube widgets are rendered.
ListView is the best option for listing lots of data. It has very efficient loading property. But if you do not want it any specific reason, you have to use ScrollView and in ScrollView, you have to place a LinearLayout and in that LinearLayout, you have to place multiple LinearLayout(for each items of data).
Maybe you can use a ViewPager (available also for lower versions of SDK through compatibility pack).
http://developer.android.com/training/implementing-navigation/lateral.html - see also the project example top right of the page : EffectiveNavigation.zip
You can use a GridView, if you want to show multiple items on a page in a different fashion than in ListView.
You can also use ViewPager (from android 3.0, or with the support library) with your custom views.

Categories

Resources