I want to create a list like seen in the picture below and was wondering which one of androids controls would be the best option to do so?
For every row in the list I could use a custom view that has max-Val and current-Val, then draw a rectangle based on that.
But for the list, the headings, and the today indicator: What control should I use here?
RecyclerView is probably the way to go.
Define different view types for
the actual header,
the section headers, and
the list items
Setting it up like that will get you the whole screen except the 'Today' marker.
To add that marker you need to draw on top of the views in the recyclerview. There are 2 options
Just add another view on top of the recyclerview where you draw the text and line, which is possible but not really the cleanest approach, or
use a RecyclerView.ItemDecoration with which you draw the 'Today' text on top of the first item after the header, and decorate (draw over) every subsequent view beneath with the vertical line.
Related
Hi I need to implement the layout as attached in pic. I have tried this StackOverFlow answer
but the resultant view get created as attached below
I need that bottom right corner to be above next cell of recyclerview.
Please suggest how can make top of the cell below previous cell.
It looks like you're close. The problems you're seeing here are:
The offset you're using in the item decorator from the example you used isn't large enough - hence the black gaps
The order in which your linear layout manager is stacking your views is from the top, which means that the row below will draw over the cell above.
To fix this, first, add a bit more offset to get rid of the black gaps.
Second, call setReverseLayout(true) on your LinearLayoutManager (can also be done via the constructor) - this will make it draw the bottom items first, so that the cells will draw above the cells below.
Also, you might want to play around with the elevation of the views to get that neat shadow effect, making sure that a row at index N will have a higher elevation than a row at index N+1. You could do this by calling myView.setElevation((getItemCount() - position) * SOME_DP_AMOUNT) when binding each view in your adapter.
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.
When covering a view with an overlay I am aware that I need to use a FrameLayout, and the child views stack on top of each other. Setting a view to having a background with opacity will create the overlay effect. However, in my situation, I am required to create a hole in my overlay to display the contents of a tab item / other views beneath it. This is where I am stuck.
I am not sure how to perform the intersection on the view so that it is transparent in a specific area of the view (which I need to determine based upon the position of a specific View element (Tab, ImageView, etc).
The image above shows the result I want to achieve. With the entire view having an overlay on it, besides one of the Tabs and the Info box (which needs to move based on the view displayed through the overlay).
I believe I need an intersection of the views to achieve the result I need...this is something I am not sure about. Can someone point me in the right direction of a solution please, I do not expect to be just given a solution, its all about learning!
How to create this below view.
1)using listview or
2)inflating custom view in scrollview.
This is not only problem.
If list view then how to overlap the rows.
Each row have different color and that will come from api webservice.
In listview, at each row i have problem with red part which i have marked in second image.
even each row background is different and that same color will appear in below row.
How to do texture effect in listview?
The issue breaks to many things:
How to draw overlapping views?
I would try setting negative values for vertical paddings, but it's a wild guess. Also, you can just divide the graphics and draw views as rectangles containing view N and some parts of the N+1th view.
What about non-rectangular hit area?
You can manually detect clicks using color picking, shapes, or just simplify the view's clickable area to a rectangle.
What about visibility detection?
ListView shows only views, which are visible. I'm not sure, but most likely it won't work with negative paddings or similar hacks.
Personally I would write a custom view with ListView-like adapter and dynamic row loading.
I have try a many ways, and the best and fastest is simple set negative divider to listview like so:
android:dividerHeight="-100dp"
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.