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.
Related
I have created a listview inside scrollview. Atfirst it was not scrolling but when it started scrolling then layouts below list view started disappearing from screen. is there any solution to dynamically calculated he height of list view and assign it or is it possible that some how the scrolling of listvew is disabled so that only its items appear on screen like normal layouts or any tags and it does not scrolls???
ListView is deprecated. I would suggest you to use RecyclerView and add nestedScrollingEnabled="true" to your xml or call RecyclerView.setNestedScrollEnabled(true) if you want to wrap adapterview with a scroller. You can also try NestedScrollView for support compability.
Good luck
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 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
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.
I have an Linear Layout inside the View Flipper. When i fling/swipe the layout the same layout reloads the same layout with the animations slide_left_out and slide_right_in. I just have only one layout view. it has the values the image view and text view. When i swipe the view it just change the next value to that views. Any Idea?
How did you add the swipe/fling functionality? In other words, when the screen is "flung", that's where your code has to come in and "flip" the viewflipper to a different layout.
AFAIK There isn't a built-in way to fling the viewflipper without having to write some code to handle the fling and manually change the viewflipper layout (index).
EDIT:
Basic Gesture Detection
Flipping Views using ViewVlipper.setDisplayedChild()