JavaFx BorderPane regions size manipulation - javafx

Is it possible to change default size of regions ( left, right, top, bottom ) of BorderPane regions ? In case of top and bottom change height and in case of top and bottom width?

I guess you mean "In case of top and bottom heigth changes and in case of left and right width changes?"
It seems not possible to set this sizes, but instead you can set preferredSize, maxSize, or minSize of the node of each of this regions, depending of the situation you want to prevent, as BorderPane regions resize to their Node size somehow. see "Resizable Range" in BorderPane doc.
Maybe you should edit your question and give more details.

Related

imageView constraints on iPhone X does not work

The top constraint of the imageView is set to be 9px from the header but on iPhone X the constraint gets larger. See pictures: grey area between header section and top of image. Any suggestions what might be the problem?
Pics:
Too much space between
Proper 9px space
Note:
- Picture is set to size 1080x1080
- Content mode is set to Aspekt Fill and tried also Scale to fill etc but none will work.
- ViewController consist of nested elements: View- SafeArea-ContentView- View-ImageView. Total constraint top 9px. These are nested inside another VC in a Scrollview element that is placed top:0px from header.
- Constraints set to superview top 0 in and in the headerVC to header top=0
Found a fix. Took away imageView top constraint to superView and Manually ctrl dragged a new constraint from the imageView up to the safe area.

How to properly constrain Vertical StackView with multiple labels in Dynamically heighted TableView Cell

I have a tableview cell that contains a horizontal UIStackView. Inside it is an UIImageView (on the left, 100x100 dimensions) and a vertical UIStackView (on the right) that contains 4 labels. The vertical UIStackView is constrained to the UIImageView's top and bottom anchors. But the bottom constraint is "less than or equal to".
I am setting the text property on these labels but if the text is nil I hide that label. Stack View than sets the height of that label to 0 and it doesn't appear in the Stack View. Now the idea is if some labels are hidden, the combined intrinsic content size's of the remaining labels will define the height of the vertical UIStackView and it will decrease in height based on that "less than or equal to" bottom constraint.
This doesn't work though. Take the case where the 2nd and 4th labels have been hidden. The 1st label is normal height. But the 3rd label stretches all the way down to the bottom of the UIImageView. This is in contrast to my expectation that the intrinsic content sizes of the labels would be less and the label's UIStackView would shrink.
I'm guessing there is some priorities that might need to be tuned to get this working properly. This whole view hierarchy is contained in a UITableViewCell and that has dynamic height applied which I hope doesn't cause any problems.
So if the intended behavior is that when I hide labels the vertical UIStackView shrinks, what constraints must I add/delete or which priorities must be set?

ios 10 autolayout cellview out of view

New to the auto layout world, i can't seem to right align a table relative to its parent content view in the cell. Left aligning works, but when previewing on smaller screens and when running on 6s, the label is not visible/cut off.
according to this thread, the solution was to make sure the tableview was pinned correctly to the parent view controller (0,0,0,0) - but still did not fix my label.
Any help is appreciated.
First of all, add top, left, right and bottom constraints to your tableView.
Also, your label has x position constraint, but how it should lay according to y coordinate? Add label top or bottom or centerVertically constraint.
And what about your redView? Set the needed constraint to it also.

BorderPane center overlap other parts

When I use BorderPane and put a layout in the center part , it covers other parts , how can I prevent the center part of covering other parts n borderPane
as you see , the table covers the right part of the BorderPane .
I put the table inside Pane .
From the BorderPane documentation:
BorderPane does not clip its content by default, so it is possible that childrens' bounds may extend outside its own bounds if a child's min size prevents it from being fit within it space.
To prevent overflow, some options are:
You could code your child node so that it does not have a min size.
You can ensure that the sum of min sizes of all children is at least equal to the min size of the border pane.
You can explicitly set a clip on your child node. For a demo, see: JavaFX Pane Clipping.
final Rectangle outputClip = new Rectangle();
childNode.setClip(outputClip);
childNode.layoutBoundsProperty().addListener((ov, oldValue, newValue) -> {
outputClip.setWidth(newValue.getWidth());
outputClip.setHeight(newValue.getHeight());
});
The order you set child nodes into the border pane determines which is displayed on top, so if all the nodes are opaque, you could set the center pane first and the sides panes will be painted over any overflow.

QGridLayout issue

I have a problem with when setting my centralwidget with QGridLayout. I have three widgets in my centralwidget. One is one bar in the top that covers all the horizontal length of the centralwidget and the other two are two frames, one square in the left and other one in the right.
My purpose is that the top bar won't change vertically and the left square can expand both vertical and horizontal, and the right on stays without expansion and always in the right corner of the centralwidget giving the left one space to expand.
The problem is when setting the size policy of the right one. If I put fixed the left one will take all the space.
I don't know if you get the idea. Sorry, this is the best I can explain. I would be very appreciated if you could help me.
I set a max and min length to the right widget and it worked.

Resources