Can someone help me understand the grid layout used in Nativescript, in particular the GridLayout? What does the (star) followed by auto actually mean?
<GridLayout rows="*, auto">
And then I came across this even more confusing example:
<GridLayout rows="*, auto, auto, auto, 2*">
I am finding the documentation for the Nativescript not so clear.
The documentation states the following:
A string value representing row heights delimited with commas. Row
heights can be either an absolute number, auto or *. A number
indicates an absolute row height, auto makes the row as high as its
highest child, and * makes the row occupy all available vertical
space.
I think it is important to first distinguish between auto and *, since they do something different. When you use auto as a value, the GridLayout will grab the height of the child element with the highest height value and make that the height of the row. So if you have a GridLayout with one row containing several columns, one with a height of 20, one with 30 and one with 40, the row will have a height of 40 and columns in that row will match that height.
If you use a * instead of auto then the GridLayout will use all available space for the height of that row. So if the height of your GridLayout is 100, the row will also have a height of 100. When you put a number in front of the star, you are basically dividing, so if you have rows="2*, *", the first row will have two thirds of the height of the GridLayout and the second row will have one third of the height.
I am not sure if the concept of the rows attribute is clear, but to clarify you are defining the height of multiple rows by adding commas, so for example: <GridLayout rows="*, auto, auto, auto, 2*"> contains the height for five rows. The first and last rows will use the remaining space after the height of the three columns with the auto height have been determined.
The NativeScript documentation contains some images to showcase what it looks like, which can be found here.
Related
I don't even know how to start with the problem. I've got the table with a few columns (generated automatically). Let's say there are 5 columns. First I would have to take the first 4 columns, calculate auto width for them, take the longest one and set that width to all 4 of them - so that the first 4 columns have equal width of the widest one but are as narrow as only content allow. The last 5th column then has to fill the rest of the table. Is that possible to achieve that without js with scss only?
i have a TableViewCell and i want it to contain 2 labels both centered vertically in the cell, one at the left border and one at the right border(with respective text alignment). Now the right one should remain 1 line(its only a number with max 6 digits), but if the left one gets too big and would overlap the right one, i want it to make line breaks.
Now i've tried different approaches, for example i first added the right one and gave it the constraint "trailing space to superview = 0" and "center vertically in container".
Then i added the other one, gave it the constraints "leading space to superview = 0", "trailing space to rightLabel = 0" and "center vertically in container" and set lines to 0.
But that didn't work, it didnt make line breaks and overlapped the right label.
How can i achieve that?
You need to set the correct content-hugging and compression-resistance priorities (by default they have the same value), that's why the system doesn't know which constraint to break.
Try changing the content-hugging and compression-resistance priorities so that they are no longer equal. The system breaks the constraint having the lowest priority first.
Select the label. Open the Size inspector, find the Content Hugging Priority and Compression Resistance Priority settings. Change priorities.
I have 2 labels that are stacked and have a bottom space constraint to their common container. I want to hide the lower label if there's no value for it and move the upper label down to the lower label's position. I can do that easily with an outlet bound to the bottom space constraint for the upper label.
The problem here is that these labels have different font sizes. So, when I set the same value for the bottom space constraint for the upper label, like I have set for the lower one, the upper label does not end up at the same vertical position.
I assume this is because these labels have different descenders, due to different fontsizes. It would be easy to solve that if I could set the bottom space constraint not for the frame of the text, but its base line. I'd like to do this in IB, if possible.
I don't think it is possible to set a constraint to the strings baseline. Your comma is way bigger in your upper label, thats why the numbers don't sit at the bottom of the label. If you make the label smaller, you cut those commas of.
I see two solutions here:
Leave it that way.
Set the constant of your constraint to something lower than 0 (I guess -2 to -5) so that your numbers perfectly align with the smaller label.
I was able to create a chart using sub groups in the manner described here. The results look like this:
I'd like to be able to control width of the colored bars as the number of categories within them increases, rather than just have the category width decrease in width to fit a constant major group width. As a result of this, as the data increases, I'd like to have the "excess" graph just go off the div, like so:
and the excess would be access by means of scrolling, I guess with .css .scroll property.
How does one achieve this kind of look?
With jqGrid if width of columns are not specified, they share the width of the grid equally. (ie. if the width of grid is 400px and there are 4 columns, they all occupy 100px width). Is there an option to handle this in a smart way so width of the columns can be upon their content?
For example let's say there are two columns: name and info. Assuming average length of names is 60 chars, whereas average length of info is 400 chars. If the grid has a width of 460px, name column should has a width of 60px and info column should has a width of 400px.
Some kind of autowidth-to-content functionality is needed. I think there is a little possibility about that because if I dynamically resize the grid, then the width columns somehow changes and fits according to their contents.
Thanks in advance.
You could dynamically resize the grid in the `loadComplete', to make column width better fit the content. Normally I will just choose column widths that are satisfactory for each row and that tends to be good enough. There is also a method for showing an ellipsis for content that is too wide to fit within a column, although unfortunately the technique is error-prone in firefox.