I am attempting to create a nicely rounded list similar to the one shown below:
The items displayed will scroll when a user wishes to pass 6 items. I was wondering how I could make the recycler view, within this rounded cabinet, rounded at the top and bottom; such that an effect is created to match the draft displayed above.
If anyone could tell me how to round the corners of a recylcer view, cleanly without artifact, like this (within XML) it would be greatly appreciated. Just for information, I have tried something; that being the process of putting the recycler view inside a cardview and allowing the cardview to clip the recycler. However, this results in some weird pixel outlines (artifacts) at the bottom edge. I have shown it here:
You can see a set of stray pixels which, while not neccesarily too obvious, make it slightly jarring to view for both a user and myself
Related
Is there any way to make following Layout in Android..? If yes please suggest how to make and how to set clickListener's of overlapping areas of Views...? i.e View 2's area overlaps 1's area and View 3's area overlaps 2'sand 4's area and so on others views overlaps..? If there is any android library to make non-rectangle buttons/Views also suggest.. Thanks.
Here is one way that this may work:
Use a rectangular ImageView for each shape. Make sure each shape is clickable.
Shape images will have a transparent portion where they fit together.
Use FrameLayout or some similar layout that will allow overlapping of Views. You will have to work with how each View overlaps.
Make the transparent portions un-clickable. See this Stack Overflow question and its accepted answer regarding one way to do this. (N.B. I have not tested this.) You should be able to work it so that clicks propagate downward to an underlying ImageView when a transparent region is clicked.
An alternate way would be just to have two views (left and right) and implement a View.OnTouchListener to determine where the click occurs by looking at adjoining pixels: their color and placement.
Good luck!
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!
I'm experimenting to see if the layout scheme I want to use is possible. I want to have an XML layout that's scrollable. Within that scrollable layout, I want to have a single line going horizontally across the screen (I used just a View with a fixed height and different color). When that horizontal line reaches the top of the screen, and as I scroll down through the layout, I want it to stop and remain at the top of the screen while being able to scroll through everything below it.
I've been messing around in XML trying to get it to work, basically putting a bunch of junk before it and after it.
Any ideas as to how that might work? Would I have to do something fancy with the java code to fix the red line at the top when the scroll position reaches a certain point? Your help would be greatly appreciated.
I am assuming you want something like Gmail app where when you scroll a mail the header sticks on top... To do this, you need 2 views. You have your regular scroller below and overlay a fixed view on top (you can use a relative layout to do this). When your cell goes past a certain spot, you want to populate and set the visibility of the fixed view to VISIBLE. This would give the impression that the view you want to 'stick' to the top really just got stuck rather than scrolled out of view. You'll have to work out the opposite scrolling scenario too based on the location and height of the scrolled cell/view.
HTH
i was requested to make in android a view that groups several items like checkboxes or text views in vertical rows, separated by transparent dividers while the background is with a certain alpha level and the edges are round.
I thought of two solutions and i hope for some feedback on good\bad or other solutions if you got'em.
just use regualr linear layout but have a single style A that uses a 9 patch as background, includes padding,margins and whatever i need to make it look like what i want. i then create another style A.up and A.down that represents the upper most and lower most items that will use a different 9-path with round corners.
inherit from linear layout, in the onMeasure and layoutChildren add to all the children some kind of space between them, i can create new attribute for it that can be customized in a style. i can override the dispatchDraw to paint the background for each view before it draws so i can paint my round borders, my only demand will be that each View added to this layout will have to be with transparent background.
So what do you think ?
Eventually i decided to use a List with customized divider.
It looks good, however a list got a very nasty bug when it comes down to items with states like buttons and clickable textViews,
you get no focus for the item and don't see the ornage bar
you don't seem to get the evnets flowing to the children of the View in the list.
I'm notsure how to resolve that one, i've seen numerous mails about it in the developres mailing list and here, most saying don't put statefull objects in a list.
So it mist not be the solution for me.
Nest thing i'll try is extending the normal layouts to have a bar in their bottom and use regualr linear layout with round corners drawable.
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.