Scroll another HorizontalScrollView though one is scrolling in android - android

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.

Related

How to detect if an HorizontalScrollView is showing scroll bars or not

I have an HorizontalScrollView in my design, which I populate with a variable number of items. The problem I have is that sometimes I populate it with many items, so the ScrollView shows scroll bars. That's OK, but I would like to check this situation and show a Previous and Next buttons in this case.
How can I do this?
I don't think ScrollView has a scroll listener. Synchronise ScrollView scroll positions - android might help you for creating a custom one.

Scroll before ScrollView is loaded

Hello, I have a question,
Is there any possibility to skip the first scroll's that occur before gridView is loaded?
To get only those when user really scrolls my list?
I am loading more, and that scroll before any user action is messing up.
How are you loading the gridView?
If you load it using addView you probably won't have problem.
In my opinion the best solution is to create a scrollView that contains a LinearLayout (for example vertical), then add at this LinearLayout a list of LinearLayouts (horizontal), and every layout contained in list contains yours elements.

scrollView linearlayout and listview

I'm doing an android app, and I just want to have an scrollable layout, but inside of this layout I want to put some textView and 2 listView, and this is my problem, the listView.
I need to include this 2 listview on the layout and this is obligatory need to be scrollable, and I googling and all I found is negative.
how can I put 2 listview on scrollView?? is not possible? and if its right what can i do? Which is the alternative that I have? I really desesperated because I spend all day!!
con someone say me an example of this?
really thanks!
ListViews shouldn't be placed inside a ScrollView because the ListView class implements its own scrolling and it just doesn't receive gestures because they all get handled by the parent ScrollView. However you can add views you want to be scrolled to the ListView as headers or footers.

Is it possible to have a ScrollView inside another ScrollView?

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.

Scrolling two views together

I currently have one Scrollview which contains a table layout and one
list in my activity. Now my problem is that I wanted to move both of
them(Scrollview and list) together and with proper synchronization...
So if scrollview is being scrolled then listview should also scroll
with the same distance, and vice versa...
Thanks in advance..
Abhishek
create your own scrollview and override all scrolling related function to do your custom actions.
In the listview you can make use of
[AbsListView.OnScrollListener][1]
to make magic :-)

Categories

Resources