I am generating a custom View that contains a number of drawables that are added to the View dynamically. This means the View's size could be anything, and is likely to stretch off the screen. Where it does stretch off the screen I want scrolling to be enabled.
So far I have tried:
adding the custom view directly to my Activity - this displays the drawables ok, but with no scrolling
adding the custom view as a child to a ScrollView and setting the ScrollView as the content in the Activity - this doesn't display anything.
How do I generate a custom view of arbitrary size, display it and have scrolling where it is too big for the screen?
Adding it to a ScrollView should be fine. Remember:
A ScrollView is a FrameLayout, meaning
you should place one child in it
containing the entire contents to
scroll; this child may itself be a
layout manager with a complex
hierarchy of objects. A child that is
often used is a LinearLayout in a
vertical orientation, presenting a
vertical array of top-level items that
the user can scroll through.
To make sure your "custom view" is working fine, first try to add a LinearLayout to the ScrollView and then add drawables to the LinearLayout.
Related
i have a fragment which has a stationary Image View at the top , some linear layouts to display the texts and List View at the Bottom. i want the entire screen to go up(that stationary Image View and middle part) when i scroll down in the List View.
I tried to place all layouts in a single Linear Layout and put it inside Scroll View since it has only one direct child..but that makes only the List view scroll able.
Try using CoordinatorLayout and scrolling behaviour from the design library.You can find a great tutorial here
I need to place an expandable listview to the end of a page that displays some data in a scrollview. Basically the listview contains some user comments for the page. The page contains a lot of dynamic data so that it can be placed in a scrollview only. When i add an expandable listview to the end of the scrollview it falls in the right position. But when i expand the listview & set the parent view to wrap height, a part of the listview get clipped of. How can i handle this. I have tried setting the layoutparams of Parent view to wrap content. But that doesnt work.
PS: The cell sizes of the expandable list items is variable.
EDIT: The structure of my xml is
ScrollView
LinearLayout
Comments layout is inflated here along with some other layouts
Comment layout is
LinearLayout
Expandablelistview
I am tring to set the sizes of parent layout dynamically after calculating in onExpanded & collapsed
I have a child layout within a scrollview that contains many objects that move around depending on their layout size (having attributes like centerVertical=true). The problem is that the scrollview won't begin scrolling until the layout becomes as small as possible, which makes many of these objects overlap each other. I'm trying to correct this by setting the child height to a custom value, however the entire layout becomes jumbled then. I have fillviewport=true, I'm just trying to find a way to control the height of the child inside the scrollview because it is deciding to make it too small by itself. Thanks!
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?