How to fill RecyclerView equally with LinearLayoutManager in XML? - android-recyclerview

I have a huge thing that I cannot understand! Hoping on your help!
Example:
6 children are
Equally filled in RecyclerView by height with GridLayoutManager. But I need LinearLayoutManager(Don't ask me why, it doesn't matter).
Example using GridLayoutManager - all 6 children are equally filled:
Example using LinearLayoutManager - 6 children filled and a huge white spot is left at the bottom:
So, how to fill RecyclerView so it would fill the screen with 6 children with LinearLayoutManager as it is filling with GridLayoutManager?
I'm asking how to make it in XML!!!
Thank you!

Related

Get how many pixels do the Viewholder (RecyclerView) moved when swiped

Hello i am using a recyclerView and i am wanting to know if there exist any way to
get the pixel position of the row Viewholder beign swiped.
Any ideas?
From ItemTouchHelper.Callback override onChildDraw as it gives all info you need , or use a helper like this and see usage here

ngx-charts-bar-vertical-2d minimum bar width

I would like to set the width of the bars to be a minimum of 12px. I would actually prefer to have a fixed width on the bars period.
As an example, when I am displaying 10 days of data, the graph looks fine, but for 30 days, it does not look good at all. Any thoughts on making this look better?
I added a horizontal scroll, but the width of the bars is automatically calculated based on the number of items in the graph, irrespective of the graph width. Is there any way to alter this behavior?
Screen capture: https://share.getcloudapp.com/yAubDN8X
Try adding [barPadding]="1" to ngx-charts-bar-vertical-2d element
<ngx-charts-bar-vertical-2d [barPadding]="1" ...>...</ngx-charts-bar-vertical-2d>
Try adding [groupPadding]="1" to ngx-charts-bar-vertical-2d element
<ngx-charts-bar-vertical-2d [groupPadding]="1" ...>...</ngx-charts-bar-vertical-2d>
as long as you minimize the padding between groups, the barWidth with grow automatically !

NSTableRowView "Empty Rows"

I've overridden NSTableRowView, which so far is working a treat. The problem I'm facing is drawing the separator for the empty rows.
drawSeparatorInRect:dirtyRect
only seems to override the rows that have content, all the rest seems to be filled with system colours.
At the moment I have:
-(void)drawSeparatorInRect:(NSRect)dirtyRect
{
NSRect sepRect = self.bounds;
sepRect.origin.y = NSMaxY(sepRect) - 1;
sepRect.size.height = 1;
sepRect = NSIntersectionRect(sepRect, dirtyRect);
if (!NSIsEmptyRect(sepRect))
{
[[NSColor gridColor] set];
NSRectFill(sepRect);
}
}
Which, as I said works well. I originally picked this up from some apple sample.
When I change the separator color to "red", you can see what happens:
The bottom-half of the last populate row is filled, but none of the others there after are.
Has anyone got an idea what I'm missing?
Cheers,
A
There are only row views for rows which have content. Therefore, a custom row view can not affect the drawing of separators for rows past the end of your table's content.
To customize the drawing of those separators, you need to override -[NSTableView drawGridInClipRect:]. You compute the position of the separator for where rows past the end of the content would be and draw the same way as your custom row view does.
This is explained, with example code, in the video for WWDC 2011 Session 120 – View Based NSTableView Basic to Advanced. It's also demonstrated in Apple's HoverTableDemo sample project.

Knob drags beyond right boundary [More 1.5.1]

When creating a nice slider using Mootools More 1.5.1 Slider class, I noticed that the 'knob' can be dragged too far to the right.
Consider this slider scenario:
|--|~|----------------|
I find I am able to do this:
|---------------------||~|
which is no good when the parent div has overflow:hidden set.
This occurs because the Drag object in the Slider class sets the left most x position ( limit.x[1] ) as the width of the passed in element (parent of the knob).
I would expect this limit to be the the element width minus the knob width.
I get the same problem whether the 'knob' is inside or outside the 'element' (above and below in the DOM).
The only way I could fix this was with a hack:
if(mySlider.drag.options.limit.x[1]===mySlider.element.getSize().x){
mySlider.drag.options.limit.x[1] -= mySlider.knob.getSize().x;
mySlider.drag.setOptions(mySlider.drag.options);
}
Check out this Fiddle (examples of broken and hacked).
Am I missing something here? Or should this be raised as a bug?

Two NSTextFields with interdependent widths in autolayout

I’m trying to put together what seems to be a simple case of two NSTextFields with dynamic width and fixed spacing in between. I cannot figure out an effective way to do so though.
I’m looking to get something like this:
The blue boxes are the NSTextFields. When more text is entered into one, it should grow and thus make the other one shrink, maintaining the lead space, trailing space and the spacing in between the fields. The first one should take the priority if both of the fields have too much text. Each field will also clearly have a maximum and a minimum possible width it can reach.
How would I go around handling this, preferably utilising IB autolayout as much as possible?
It seems to me that all of constraints you mentioned directly translate into interface builder --
First view has width >= something.
First view has width <= something
Same for Second view.
Space between views is fixed.
Second view wants to be as small as possible (have its width at 0) but this has lower lower priority than the previous constraints and lower priority than inner content size constraints.
The code I had to add to my view controller, after applying the constraints as per the ilya’s answer:
In controlTextDidChange (_controlWidthConstraint refers to the fixed width constraint of the input; it’s probably 0 by default for the second input):
// Get the new width that fits
float oldWidth = textControl.frame.size.width;
[input sizeToFit];
float controlWidth = textControl.frame.size.width;
// Don’t let the sizeToFit method modify the frame though
NSRect controlRect = textControl.frame;
controlRect.size.width = oldWidth;
textControl.frame = controlRect;
_controlWidthConstraint.constant = controlWidth;
The key lies in invalidating the intrinsicContentSize for the text field when text is input.
You can check a sample project here, to get you on the right track.