I have a horizontal scroll view, and inside I have a number of image views, they go across the screen and altogether are wider than the screen.
I've tried to scroll through them using touch, but nothing happens, am I missing something?
Inside HorizontalScrollView, put a LinearLayout with orientation Horizontal and add ImageView to that LinearLayout
Related
I need to be able to make a bi-directional RecyclerView. Basically, it would scroll vertically, but each row would be a horizontal list of tiles that could scroll. The initial scroll position would be at the top and left. The user could scroll down, and scroll to the right with each row.
Any ideas on how to do this? (e.g. with a custom LayoutManager or touch event interception).
I was able to solve the issue using a custom view implementation.
At the root, I have a custom ScrollView; when onMeasure is called, the ScrollView tells its children how tall they should. In this case, they are half the height of the ScrollView. The width matches the height so they display as square tiles.
Each of the ScrollView children are RecyclerView's with a horizontal LinearLayoutManager. Since the ScrollView tells each child how tall to be, there's no issues with measurement and they actually scroll very well in both directions (vertically and horizontally).
I have a LinearLayout containing two ImageViews. The LinearLayout is inside the ScrollView.
When I scroll the screen I would like to know the exact position of the two ImageViews relative to scroll. The getScrollY() doesn't work correctly because the ImageViews continues scrolling after action_up and the value in getScrollY isn't updated in this case. I have this information to disable or enable other elements on screen.
If your 2 views are the same/similar then add them to a ListView, then you can set an OnScrollListener which will tell you when the view is scrolled and the index of the visible item.
I have a view animator that I am adding images to dynamically via a web service call. However, the scroll bar refuses to show up no matter how many pics I add to the ViewAnimator. Thoughts?
The ViewAnimator is not a scrollable layout. Adding a childview to view animator will not show the added view if you don't have a mechanism to call showNext or showPrevious.
Maybe you want to use a ScrollView instead? You nee to create a ScrollView that contains a LinearLayout with a vertical orientation. You can now add images dynamically to the LinearLayout and the ScrollView will increase in size.
Let me try to explain what I want to achieve. Currently, I have a ScrollView as the main view for my layout and a linearLayout within that to place all of my content into.
In my LinearLayout, I have a bunch of textviews and a gallery, which extends out of the screen, so the user can scroll to see everything. It works.
Now, I want to add an expandableListView to the bottom of all that content, which is still in the linearLayout. The problem is when you expand the list view groups it doesn't affect the ScrollView. I had envisaged that when you expand a group it would make the linearLayout bigger, which in turn makes the scrollview bigger.
Is what I'm thinking achievable?
EDIT:
Ok I think the situation is that listViews are normally placed in a layout by themselves and have scrollviews already enabled. You just set it to fill_parent and it works fine. However, in my case, I'll need the expandableListView to display all content without scrolling, because my ScrollView will deal with that. I don't even think it possible?
It's difficult to answert without seeing your layout xml, but I think that if you set the android:layout_height of the linear layout and expandableListView to wrap_content, the first scrollView must scroll the whole view.
have you tried putting your expandable list into another linear layout and than put it in the scroll views default linear layout?
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.