I'm wondering how to implement a horizontal list of users, that become bigger and brighter once they are chosen:
I'm thinking about ViewPager with overriden getPageWidth so that it shows 3 items at the same time, but I don't know how do make the sibling views look differently then the one in the middle.
That would have been pretty easy to achieve with the Gallery widget that is now unfortunately deprecated.
But there is the EcoGallery project https://github.com/falnatsheh/EcoGallery that has the same functionalities and works pretty well.
To transform the view in the center you can simply subclass the EcoGallery and override the
getChildStaticTransformation
method.
BTW you can override exactly the same method also on the ViewPager.
It's pretty easy to find loads of good examples of how to use this method.
Related
I am trying to achive this:
First I tried by putting all my recyclerviews (with WRAP_CONTENT) inside a nestedscrollview. That worked, but the performance was awful. Then I tried to set a height for my recyclerviews, that was a lot better (especially the first gridlayout and the horizontal linearlayout loaded very fast), but still had the problem with the dynamic "category" part.
Now I am trying to put all my recyclerviews inside a single recyclerview with different viewtypes. Since that is a pretty big deal (I need to refactor a lot of code because I have diveded every area from the screenshot inside a single fragment and now I need to put all that code inside an adapter) I wanted to ask if I can actually expect any gain from this, because in the end its again a "nestedscrollview" (made by myself, but...). Or if there is some other "best practice" way to achive this layout.
Thank you
Edit:
As expected this didnt do the trick neither. When just the two first recyclerviews are added as viewtype it scrolls and loads smoothly. But as as soon as I try to add the category items (below the category), I notice a lag and especially when selecting multiple categories and scrolling fast up, there is noticable lag. I guess I will have to change my layout and move the category selection part inside a separate view, just need to come up with a user friendly solution. But its acutally quite dissapointing that, in my opinion such trivial task, laying out multiple tables, is such a pain in the ass on android.
I didn't manage to get it working with standard android stuff.
Now I am using epoxy from airbnb ,and I have converted all my views from nestedscrollview to the epoxy recyclerview. Its a great library, and airbnb use it too for all their views.
Nevertheless it's sad that the android dev team doesn't address this problem and provide a solution besides the info "don't nest multiple scrollviews(recyclerviews) that scroll into the same direction".
You can use Recyclerview in recyclerview.
https://irpdevelop.wordpress.com/2016/02/10/horizontal-recyclerview-inside-a-vertical-recyclerview/
And make sure to use multiple view types.
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.
I am looking for an viewpager or scrollview implementation or guidance on how to construct one that mimics that of the Circa News application, shown below.
The ViewPager or ScrollView implementation needs to be able to handle views or fragments(either, not or) of different sizes. Allowing for any size, smaller than full screen and larger also. The focus would be on the top most(top aligned) view/fragment. The scrollbar indicator on the right side is not a requirement.
So far i've found Mark Murphy's analysis on the basic problem, but all of the results don't fit the situation exactly. Link
I ended up finding this answer while looking for something else, but it partly works for the question i posed with a few caveats.
Parchment is a "Horizontal/Vertical ListView, GridView, ViewPager, and GridPatternView". The key part is the ViewPager, but bad part is its not its a listview and does not support fragments as a normal ViewPager would. But you can achieve the same result.
You use Parchment like any other ListView, the key is in the configuration(which i believe can only be done via xml).
<mobi.parchment.widget.adapterview.listview.ListView
android:id="#+id/verticalviewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
parchment:orientation="vertical"
parchment:isViewPager="true"
parchment:snapToPosition="true"
parchment:snapPosition="start" />
The key is "isViewPager", "snapToPosition" and "snapPosition". This enables the list act like a ViewPager. Only difference is the views are from an Adapter's getView() instead of a fragment.
I was really surprised that such a Widget gets deprecated.
I want a simple gallery that scrolls left and right, shows a picture on the whole Activity screen, and most important is that you cant swipe more than 1 image in any direction, even if the scroll speed is fast it changes to the next image.
So which Widget should I use? Or should I use a simple ImageView and handle all the swipes and add an animation?
It states in the docs:
This widget is no longer supported. Other horizontally scrolling widgets include HorizontalScrollView and ViewPager from the support library.
HorizontalScrollView will be closer to what you are looking for I think.
I suspect that Gallery was deprecated because it did not properly use convertView with its adapter. Which meant that it had to create a new view for every item which was a drain on performance.
Another option you have is to use the 3rd party created EcoGallery which Joseph Earl created to overcome the issue, this version does recycle its views properly. Unfortunately that pastebin link is the only reference to it I can find online now.
I am new to android therefore I got a little bit lost with all those ViewFlipper, ViewSwitcher, ViewAnimator and ViewPager. Moreover, I am not sure what's happening under the hood.
Basically I have an activity which shows some data. With swipe (or button, doesnt matter) I would like to scroll the view and get to another page (as seen in the picture below).
Is it possible to implement something like that without changing to another activity?
I am a little bit confused regarding views and access to the design elements. How those pages are located each to another? e.g. If I am currently seeing Page1, can I modify content of Page3? Or plainly saying, are all page views loaded all together? As if I set setContentView(R.layout.xlayout); then I can access only xlayout elements.
But if I use same activity, then I have a thread there which updates a counter on Page1, if I change view to Page 2, the counter will not find Page1 Counter TextView and will complain.
As I Understand Android 4.0 has ViewPager which is similar to the seen in the picture. I am using GB. Should I use support library or can I just go around and implement something similar without importing any libraries?
(Sorry, my description is a little bit messy)
Yes, you can use ViewSwitcher, ViewFlipper and ImageSwitcher depending on your requirements.
ViewSwitcher may have two childs at max. And these child might be a View or an object of subclass of view.
ViewFlipper: May have as many childs you want. and these child might be a View or an object of subclass of view.
ImageSwitcher might be used to switch images over.
By using view flipper you can display one item at a time, and adding a gesture overlay, you can apply sliding effect. To apply View Flipper, you need to add all the views to ViewFlipper, and showNext and showPrevious methods are used to show next and previous child.
You need to use a ViewPager to have the same behaviour as in Google Play.
it only available on recent version of Android, but you can use the Compatibility Package to make it available for older version.
With a ViewFlipper you can't "scroll" between two pages.