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.
Related
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.
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.
I want to learn how to solve this problem. I want to have a Horizontal scrollview with the scroll blocked (the user should not be able to scroll it) and inside that horizontal scrollview i want to have another horizontal scroll view, and this scrollview must be able to be scrolled by the user (it haves more content that the width of the screen).
Is it possible to do it?
I tried using this on the parent horizontal scroll view:
((HorizontalScrollView) view).setHorizontalScrollBarEnabled(false);
((HorizontalScrollView) view).setEnabled(false);
((HorizontalScrollView) view).setFocusable(false);
((HorizontalScrollView) view).setFocusableInTouchMode(false);
and this on the child horizontal scroll view:
((HorizontalScrollView) view).requestFocus();
It is not working, the child appears to have a scroll bar, but it cannot be scrolled.
How can this be solved?
PD: I know that this is not a good practice, but I want to learn how to achieve this goal.
You should never use a
HorizontalScrollView with a ListView,
since ListView takes care of its own
scrolling. Most importantly, doing
this defeats all of the important
optimizations in ListView for dealing
with large lists, since it effectively
forces the ListView to display its
entire list of items to fill up the
infinite container supplied by
HorizontalScrollView.
http://developer.android.com/reference/android/widget/HorizontalScrollView.html
UPDATE:
Since you may be forced to use a two dimensional scrollview, you may consider using this:
http://blog.gorges.us/2010/06/android-two-dimensional-scrollview/
I haven't used this but it may be a reasonable approach.
you can do it. But you have to handle child layouts in scrollview i.e ScrollView can host only one direct child.
I want to make the same implementation a pulse application.
Horizontal list view inside a vertical list view.
i tried this project for horizontal list view, but when i am trying to scroll horizontal the vertical scroll active and the list is goes up and down.
how can i prevent this issues.
it's work on my app...
just like pulse app... horizontallistview inside vertical listview
this is the solution...
just put this code in u'r onscroll of HorizontalListview class...
ViewParent viewParent = getParent();
if (viewParent != null) {
viewParent.requestDisallowInterceptTouchEvent(true);
}
It would be much easier if you paste your piece of code with your question, allowing to see why it goes wrong. My best guess without this information is to check you usage of fill_parent vs wrap_content.
i think you should use some horizontal scrollviews in a vertical scrollview. and in each horizontal scrollview, you can give listview, gridview, etc... if you want. I think it's better solution for this problem. :)
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