Positioning of android list items - android

I want to have ListView with some customized (layout) items. Background for those item has transparency on its bottom side. I want next item (after this customized) to be positioned a little bit top (something like minus margin in CSS). If in LinearLayout of list item (this special list item) I can do android:layout_marginTop with minus values? It seems to doesn't work, so what is the better solution? I need to little positioning next list item.

I don't think that the listView exposes this functionality. As an image trick, however, if you can modify the images, just put the transparent section (I assume it's a shadow?) on the top of your listItem background image so that it LOOKS like the item above casts a shadow, but in reality the shadow is part of the background of your listItem

Related

Design in RecyclerView item

Good day, I have items in RecyclerView I would like to add a blue strip with circles, with different start and stop circles like there is in attachment.
The question is, what is the best way to implement that design ?
A simple approach is to create three icons that represent the start, regular and the final stop and that are sufficiently tall to cover the entire item height.
You can then create an item layout consisting of an image and a text view.
In the adapter of the recycler view, you then assign the appropriate icon and name of bus stop to the item view.

Android - correct way to highlight multiple image items in Grid/Listview

I have a list view in my app with elements where an image covers pretty much all of the view. There was an article by google where they explain that selectors should be drawn on top of the item if the item's background is not visible or else you wont see the selection highlight. Can't find this article anymore.
The list view has been correctly configured with drawSelectorOnTop and a selector for various states. Each item on a list view is a RelativeLayout with a background selector for various states including activated. When selecting multiple items and marking them as checked, the items are correctly marked but since a big image covers almost all of the view, just a fraction of the background is shown in the highlighted color.
I fixed my problem by wrapping the relative layout into a frame layout and setting a foreground drawable to draw the highlights. It works, but I don't like adding the extra layout on my elements.
Ideally, the selector of the listview should be used to mark the items, but apparently not. I included all possible states on the list view selector but it never leaves the item highlighted.
My question is: is wrapping items in a framelayout the correct way of doing this or is there a better approach?

How to make the background image not interfere with text when the image has icons

I currently have a very plain ListView with no background image and just text for each item in the list.
Some people have voiced the problem that it isn't intuitive to click on the list items.
So I am researching what kind of a background image to create so that it makes the list item look "very clickable"
One option is to have the background image contain those little icons on the right that look have something like a ">" and its a sign that it should be clicked on.
But I am wondering what if the text is long on the listitem and it will overlap over the ">" icon. How is that usually handled? Is there a way to make text only extend 90% of the entire listitem?
Thanks!
The easiest and cleanest solution would be to make your TextView width match_parent and use the android:drawableRight attribute in your XML to specify the drawable that you want to be displayed on the right side of your text.
If you want to do something like every item on list should be shown clickable, just do one thing, design a layout with text view and inflate that layout in your lsitview adapter class in getview method. and instead of return convertview, return your inflated view from there.

Attaching a fixed, transparent, header to a ListView?

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.

Handling an embedded view inside a ListView?

I have a quite problematic UI layout to implement, and I'm not sure if it's even possible using standard UI widgets. It looks something like this:
Picture 1
The green, lined thing is supposed to be a ListView, and the red rectangle is another View. This red View should be scrolled with the ListView, as if it's part of it. Some list-elements should also be narrower, because that embedded View gets in their way. Could you please recommend any ideas? Can this be done somehow with the Android UI framework? I was thinking about some kind of a floating View above the ListView, which reacts to the List's scrolling events too, but it doesn't seem like an elegant solution.
Thanks
I don't think you can accomplish that easily with a ListView. You could do the overlay using a FrameLayout, but it would be very awkward to get it to stay probably aligned as the user scrolls.
How many elements are you talking about?
I would probably use a LinearLayout within a ScrollPane to simulate the ListView.
Or, a TableLayout where the overlayed view is contained within a single, complex row.
I would set the green rows that the red block overlap and the red block as one big view in the listview. So the items in your listview would be (for the example pic) two green rows, then the view of three green rows and the overlapping red block, and then the remainder of the green rows.
Trying to have the red block on an overlay that scrolls with the listview sounds like more trouble than it's worth.

Categories

Resources