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.
Related
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.
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!
EDIT: Solved this by from Java-code adding headers and footers with transparent background to the ListView.
Hi, I'm trying to make a ListView that has a gradient as a background and the content inside a frame. I have some screenshots of what I'm trying to acheive.
The first screenshots shows how I want it too look from start. The list is shown in a box with rounded corners and a green background. This is acheived by adding padding to the LinearLayout surronding the ListView. However, when I add padding on top, the scrolling looks like in the third picture, which is not what I want. The first field with name and phonenumber is a header for the listview.
Any suggestions on how to make the listview behave like this?
You should use Relative layout for solving this problem.
I am trying to create an UI just like the attached image!
How do we create these types of UI? Is it a ListView? And how do we get the arrow button on the right hand side? How should I start with such kind of layouts?
You can achieve that with a LinearLayout too.
Have that LinearLayouts orientation be vertical. Create such list items (it isn't related to ListView) using RelativeLayout.
Have the icon be an ImageView aligned to its parent left and vertically centered, the text would be a normal TextView which is to the right of that icon and vertically centered as well and finally another ImageView but this time aligned to its parents right and vertically centered.
These is the receipt.
It's a ListView, you should learn how to write your own ArrayAdapter and returns in the getView method the View you want to be each row of the ListView.
AnDroidDraw lets you create the layout online and then later download it on your device. http://www.droiddraw.org/
Create appropriate custom ArrayAdapter for this layout.
I have three items in a ListView. The reason I have chosen the ListView is so I can use a Divider and a List Selector on these items.
However I do not need/want the scrolling aspect of the ListView. Ie. When I select/drag an item from the list, I dont want it to scroll..
Is it possible to disable this somehow? Or will I have to add the items using a LinearLayout and find another way of using a list divider and selector?
I'm not sure how well this will work for you, but you can disable overscroll (available in android-9 and above):
listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
and then also hide the scroll bars:
listView.setVerticalScrollBarEnabled(false);
After this, if your list does not exceed the screen size then it shouldn't be able to scroll.
If you dont need to scroll listview, you can add the list item to a linear layout as well you can design it also through xml file.
And for put a DIVIDER to it just take a "View" widget.
Put it height 1 dip and width fill_parent. You can give color to this view through background color.
Try it. i have done it many times.