Here I am attaching one image displaying what i want to achieve.
Now, what i want to do is, when the scrollview scrolls upwards, its should scroll the "somedata" "header" and "listview" part behind the image. I have already achieve this.
Next thing should be done is when "header" comes exactly below the "Imageview" while scrolling, it should stick there and then we must be able to scroll the other items of listview.
Can anyone help me ?
First of all, you can not use ListView inside ScrollView.
You can combine your "Some data" and "header" into single layout and set whole layout as your listview HeaderView.This will make your list scrollable with header.
Related
I know that is not a good practice put a ListView inside a ScrollView, that's why I want to figure out what kind of solution can handle this.
Look at the image below:
There's a block with some stuff on the top and there's a ListView below, and all of this scrolls with the entire layout. So, the question is:
How do I achieve this?
You should have just a ListView and set a headerView to this ListView to achieve what you want.
Use header View:
ListView below scrollview in Android
or Sticky List Headers if you want to make them stick on top of the listview:
https://github.com/emilsjolander/StickyListHeaders
or use different ViewTypes with your own Adapter implementation:
Listview: Only one list item with multiple textviews
Why do you assume the reviews shown there are in a ListView? To me they just look like a handful of custom Views stacked on top of each other, not an actual ListView.
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.
I'm implementing a listview that looks like this :
So basicly I have a listview, with a headerview. My problem is to set the space between the headerview and the rest of the listview. If anyone has a clue, thanks :)
To set a gap below the header view you can just add marginBottom to the header view. That should do it. But like Pauland said, never ever EVER put a listview inside a scrollview. You are basically placing two vertical-scrolling views ontop of each other and Android can't tell which one to scroll when the user swipes!
I am adding a listview inside a scrollview in xml that xml(Screen) is loading from the middle screen. In my design I have a top part like a textview and a list view and middle part like editext and bottom part like button. Page is loading from the middle part. If it scrolls I can only see the above part. I want to load the page from above part. Can anybody tell me what the problem is and how to resolve it?
Thanks
Use android:fillViewport="true" as an attribute in your scrollview tag and it will fill up the screen.
Actually there is no need to use ScrollView with ListView. Use ListView only, you will be able to scroll the items in a ListView.
You should never use a ScrollView with a ListView, because ListView
takes care of its own vertical 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
ScrollView.
found it here
using smoothScrollTO(0,0) to fix the issue
I've been trying to get this working for some time... Is there any way to put a transparent fixed header on a listview, so it looks kind of like this:
As you scroll up, the header will eventually be a regular header with item 1 below it.
I guess I'll have to implement onScrollListener and do something like when the first visible item is item 2 in the list, start moving the listview margins by 1 pixel, until it is below the header? Or are there better ways? Any ideas on how one would do something like that?
I would make a FrameLayout... and put your ListView in it first, filling the screen. Then put a TextView on top of that. To get the desired behavior at the top, maybe have a blank element at position 0 of the list, or just make the top padding of list item 0 have the height of your header...
Does that make sense? The ListView should scroll underneath the TextView in a FrameLayout.
You can use a RelativeLayout for that, so you can get the Z axis using some properties;)
Update:
For example using a RelativeLayout:
RelativeLayout
----ListView
----TransparentHeader
Will appear in the way you show on your image.
As a comment :Android put layout elements in the order that they are defined on your xml, so, widgets at the bottom of the layout will be at the top.