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.
Related
My UI consists of a ScrollView that takes the top 50% of the screen and under that two buttons that are attached to the bottom of the screen; YES and NO. The content of Scrollview is text that for most phones does not fill up the visual area of the ScrollView. However sometimes the text can be longer, such that it fills beyond the visual area of the ScrollView, hence the reason I added the ScrollView.
My problem is this; even when the ScrollView has very little text and does not need to scroll to show all of its content it still scrolls. The user can scroll the content up a slight amount. I'd like the View to instead not allow any scrolling if all the content is visible.
Is there an easy way to achieve this? Or do I have to implement that myself?
You cannot disable the scrolling of a ScrollView. You would need to extend to ScrollView and override the onTouchEvent method to return false when some condition is matched. To get help with extending, please read the answers to Disable ScrollView Programmatically?
I want to develop an app that includes GridView and I want it to be some thing like horizontal ListView above a gridvew .Horizontal view displays images downloaded from url.I saw this touturial ( horizontal scrollview used)
and saw this to put the GridView inside scrollView because i want to put the gridview(episode #2) and horizontal view (episode #1) in vertical scrollview(episode #3) . I need to scroll the horizontal view vertically when a user is scrolling the gridview and not to have fixed position at the top of the screen.
I have no idea how to do this (use horizontal ScrollView or horizontal Listview)?
after vertical scrolling I want it to be like this (horizontal view must get scrolled vertically):
This is a custom interaction, so you probably will not be able to use a "standard" tool for this. You may want something like the FloatingActionButton (an example here: http://antonioleiva.com/collapsing-toolbar-layout/) but you also want it to scroll, so you may need to extend that class.
Also, you could use touch events to do a custom animation on the area, because you will need to track when it is displayed and the direction/distance of the motion event to collapse/expand it. You also would need to know anchors on the list, to determine when it should reappear...
This is a cool design concept, but usually "cool" = "difficult" because it's not standard.
I have a layout which has some some TextViews and ImageView on the top of the screen and a GridView. You know GridView has own scroll and GridView's ScrollListener says me firstVisibleItem, visibleItemCount and totalItemCount.
My problem is that when I want to scroll my layout from the top, I have to put my all layout into ScrollView so my GridView(ExpandableHeightGridView) does not get the correct itemcounts. If I dont put a ScrollView, I can't scroll from the top.
How to deal with this problem? How can I scroll my all layout from the top.
Remember, my major problem is getting wrong itemcounts. I want to load more items when scroll reachs at the bottom so I have to read itemcounts.
Thank you to all.
It's not a good idea to have two scrolling containers one in the other. I'd expect the GridView to misbehave when it's inside a ScrollView.
The cleanest solution to your problem would be to use the concept of ListView's addHeaderView(). As GridView doesn't support headers though, you'll have to use another Google's class, namely HeaderGridView: https://android.googlesource.com/platform/packages/apps/Gallery2/+/idea133/src/com/android/photos/views/HeaderGridView.java
I have two HorizontalScrollViews. If the user scrolls one ScrollView, the other ScrollView should also get scrolled. I am new to android and I wonder to know how can I achieve this?
If you want your two different scrollviews to scroll at the same time it means you only need one scroll view in which you cand put the content within the ones you have now. Try do make thinghs as simple as you can
Extend HorizontalScrollview like this: https://stackoverflow.com/a/6462630/1124160
onScroll in first ScrollView: http://developer.android.com/reference/android/widget/HorizontalScrollView.html#scrollTo(int, int)
Scroll the second one.
If your have number of items save in both HorizontalScrollView , then create a GridView and give number of columns equals to element in one HorizontalScrollView. In this way you can achieve your goal.
I was wondering if it was possible to set the scroll range of the android ScrollView. Basically I have a scroll view with one child in it that extends 100 pixels past the bottom of the screen. Normally the scroll view will scroll till it gets to the bottom of the child view, is there a way to get the scroll view to stop scrolling like half way and not show the whole child view? I have tried extending ScrollView and overriding the computeVerticalScrollRange() but that did not work. Any help would be appreciated.
Thanks,
Sam
Do you want it to only sometimes scroll to the bottom? Or never at all? In the case of the latter, I would suggest reconsidering your layout and removing that child from the scrollview parent.