I am using a ScrollView to display a list of items that are inflated on runtime. Like a feed of updates for the user.
While thinking about the options i got to let the user update the view with new notifications I thought about the pull to refresh feature in the twitter app.
Anyone got any idea how and if can it be implemented with a ScrollView ?
Saw there are some implementations for that using ListView but I don't like the idea of changing all of my platform to gain this refresh effect.
There is a solution introduced for implementing pull to refresh for various component which are scrollable like listview and scroollview.
Look at ChangeLog link https://github.com/chrisbanes/Android-PullToRefresh
ListView with just one element can be treated as a ScrollView. You can use the implementation for pull-to-refresh ListView and add just one item in it. I had used this trick in the past.
You can do that. You can increase the top margin of the scrollview when the user moves the finger down and the scrollview it's on it's top. Then on release fire the update and decrease the margin with animation.(You have to create your own animation to pull that off). That's the idea. If you want more particular help ask what you cannot implement.
Related
I am using RecyclerView and CardView in my project, most parameters of these two widget were default, I haven't customize it much, but two questions came up.
Why those CardViews will flash one second when pull down to refresh data which is using SwipeRefreshLayout, can I stop this effect?
Why those CardViews will adjust position automatically when scrolling? Can I stop this effect?
The layout I am using for RecyclerView is StaggeredGridLayout, it's inconvenient to post code here beause there too many code in my project to use those widget, so you can tell me which part I should post here, thanks.
I am trying to implement a vertical listview with horizontal scroll on each item just like the facebook newsfeed. Suggested apps can be seen by scrolling to right and some part of next item is also visible.
here is the screenshot :
http://i.stack.imgur.com/7JRfM.png
So I am just stuck here and don't know how to proceed.
You're probably going to need to write some custom code (which is a pretty good rule of thumb whenever you're trying to do something Facebook did on Android; they do some crazy stuff).
I don't believe you can nest ListViews in Android. There is "ExpandableListView", which lets you expand items to show more, although this isn't quite the same thing.
I would advise to just create a vertical ListView, and have the items be horizontal LinearLayouts that you can inflate yourself. You can also try making them horizontal ScrollViews (although I think this may have the same limitation as using nested ListViews).
Good luck!
I would like to implement the same pull-to-refresh UI pattern used by the Twitter app.
I have been trying to use a RelativeLayout containing a ListView, but it's really slow. How can I make it as smooth as Twitter?
I have been using the Listview's onTouch callback to get the MotionEvent, detecting when the listview is already scrolled to the top and the touch is moving downwards. Then, I adjust the top margin of the listview based on the Y coordinate. But surely that's not the way to do it, as the Listview moves down in little steps, not smoothly.
Do you know which layout should be best used?
Below is just a screenshot from the Twitter app:
UPDATE:
I think I found it. I believe the smoothest implementation is by using the ListView header. So, no need to use a viewgroup like RelativeLayout. Everything could be implemented within the ListView.
Android has a SwipeRefreshLayout for this purpose.
https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html
Is there example android code or sample android app which demonstrate animation of the views while scrolling.
For example. In a scroll view some items are not visible when you scroll the items will start to come inside the screen that time i just want to animate that view.
any help would be greatly appreciated.
Thanks.
Download this app. Here you will find tons of libraries of your use. I also seen the library which your are asking in this app. You will find source code links in the app as well.
https://play.google.com/store/apps/details?id=com.desarrollodroide.repos&hl=en
Or You can do one more thing
Just add on scroll listener and some more listeners are there by which you can detect which portion of your scroll view is visible.
Then You can add animation to those views.
Try Listview animation library.
Modify it and use.
https://github.com/nhaarman/ListViewAnimations
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.