Viewpager with horizontal as well as vertical scrolling - android

I am searching for a view pager which should have horizontal and vertical scrolling in one class.It should just need to specify the property which type of scroll we want.How can i achieve this.

Hope this link will be helpful for you: https://android-arsenal.com/details/1/1863. It has both vertical and horizontal features.

Related

Android nestedScrollView - how to make it horizontal?

I cant seem to find an option for nestedScrollView to make it horizontal instead of vertical. i have been using HorizontalScrollView but i'd like to switch to nested. Is there anyway to do this ? searching the docs i dont see it yet it does say its the same as a scrollview ?
No
I do not believe NestedScrollView can be scrolled horizontally. According to docs:
For vertical scrolling, consider NestedScrollView instead of scroll view which offers greater user interface flexibility and support for the material design scrolling patterns.
As per the text in bold, I believe NestedScrollViews were only made to scroll vertically.
While NestedScrollViews are "just like ScrollView" (link), the docs do also state that:
Scroll view supports vertical scrolling only. For horizontal scrolling, use HorizontalScrollView instead.
(Both blockquotes come from here)
There is no support to enable the Horizantal nested scrollview in android.
Support is only limited to vertical scrollview.
NestedScrollViews is not a good approach . Better approach is to use recyclerview iniside another recyclerview.

Horizontal scrollView with snapping

I'm starting in Android Development, and I'm trying to do a scrollView.
I just used a horizontalScroll view, but there is no snapping with this layout.
After some search, i found this https://github.com/ysamlan/horizontalpager.
The operation is similar to that of the iPhone but there is some trouble to use it.
How I can do a horizontal scroll view with snapping ?
Isn't ViewPager what you're looking for?

Horizontal scroll view and image views?

I want to add a number of image views to a HorizontalScrollView dynamically.
I have my scroll view:
myScroller = new HorizontalScrollView(this);
Then:
myScroller.addView(myImageView1);
This works, but I want to add more than one image view to the scroller, then it doesnt work.
Any ideas?
HorizontalScrollView can only have 1 child, so you need to put all the images inside a horizontal linearLayout and add it to the HorizontalScrollView.
HTH.
Take a horizontal scrollview, and take a horizontal linear layout inside it, then if u know how many number of images are there? take it in for loop, add them imageview one by one into linearlayout...!!
If you add ImageViews you could also use Gallery which will also scroll horizontally and you can use an adapter to set the content.
If you want to stick to the ScrollView you can only have one child, so you have to add a container like a LinearLayout where you're adding your ImageViews.
Using a HorizontalScrollView to do that is much harder than using the ViewPager class that comes in the compatibility package.
For more info, read this blog post.
ScrollView it allow only one child view,
A ScrollView should place
one child in it containing the entire contents to scroll

Scrollbars in android

Can any one tell me how i can set my scroll view with both vertical and horizontal scroll ?
You can't. ScrollView is vertical scroll. HorizontalScrollView is horizontal scroll.
The only View (in the SDK) that I know of that has both vertical and horizontal scroll is the WebView. See if you can work with that. If not, you'll have to create your own View.
If you need both horizontal and vertical scrolling, you shouldn't be using ScrollViews. Instead, as this question points out, you can use a combination of FrameLayouts and RelativeLayouts to achieve the desired effect.

Both way scrollable gridview in android

Is it possible to allow a griview to scroll both vertically and horizontally simultaneously in android? Please advise.
It doubt that would be possible. A GridView is based on an ArrayAdapter, having only 1 dimension for the items. How would you arrange them in a view that can be extended both vertically and horizontally?
Of course, if you just want to make it larger than the screen and use hard-coded number of rows/columns, you can put it in another scrollable view.
There are following two solutions and you can use one which fits your requirement.
You can use RecyclerView instead of GridView with a custom layout manager. You can read this code for help. Also, you can read this article on how to create custom layout manager. This article gives an example of how to create two-way scrolling grid layout.
The other solution is to use RecyclerView with horizontal scrolling Grid Layout wrapped inside a scroll view.
<ScrollView>
<RecyclerView />
</ScrollView>
use GridLayoutManager with horizontal scroll for recycler view.
The first solution is efficient in a way that it handles view recycling properly.
Hope this will help.

Categories

Resources