I want to set the width and height of an element to be approx 1cm. On UWP, I've determined empirically that setting the element's WidthRequest and HeightRequest to 25 comes pretty close.
Using MainDisplayInfo.Density, I would think that I should be able to compute the right value for various displays.
On my UWP display, the Density is 1. On my Android device, it's 3. So, shouldn't a value of 25 * 3 = 75 be correct ?
Unfortunately that isn't working. On my Android device, 75 is is displaying my element at about 2cm.
EDIT
Further, XF documentation Units Of Measurement, says that there are 64 device independent units per cm. According to that, shouldn't I be setting my desired width and height to 64 ? Not even close.
Related
I am using NextJS and react-pdf/renderer and my tool creates a PDF and I'd like to display it with the PDFViewer component.
The Viewer loads but only takes up a small part of the screen. Whenever I change the 'width' and 'height' attribute with relative values (100%, 100vh), it won't take it. The only way to force it, is to put specific pixel values in it, but that defeats the purpose of being responsive to the screen size.
Sandbox that reproduces my issue: https://stackblitz.com/edit/nextjs-su5bi1?file=pages/index.js
Does anyone have an idea why this is happening?
Here is your screen with a red block of pixels of 150 pels high, note how it matches exactly your frame height.
Generally you ONLY set frame height in pixel units (The cross browser default minimum is 150?) you probably need somewhere to set a style defining the height as a different number of pixels.
see comment 2 in https://stackoverflow.com/a/73201090/10802527
I'm currently working with PyQt5, where I'm designing a GUI using the Qt Designer app.
However, I'm encountering a strange behavior where, within a layout (could be horizontal / vertical), the stretch factor between two elements is not infinitely tunable, and actually depends on the size of the layout window.
Here's an example:
So this is a standard vertical layout with two empty list widgets inside where I applied a stretch factor of 1,3. Now basically I cannot apply any bigger stretch factor. Changing the 1,3 to 1,5 for instance, doesn't affect the layout.
However, if the overall size of the layout is increased, the factor 1,5 can be applied
So my question is: Is there a way to force any stretch factor no matter the size of the layout window?
(I already verified my min and max sizes, and they're set to :
)
This behaviour is controlled by the minimumSizeHint. The minimum size must be explicitly set to a non-zero value in order for the layout to resize smaller than the minimum size hint. Alternatively, the size-policy could be to Ignored. So either of the settings shown below should work for your example:
With a layout stretch of 1,5, this will now allow resizing like this:
I'm displaying a map with many MarkerIcons, all based on the same png but scaled to various sizes.
The base size is 64 x 64 and if I am scaling down, things work as expected.
If I am scaling up, the icons are cropped. I made a trivial JSFiddle that illustrates the issue - this is the code to scale icon. My understanding is the first size is the actual size of the source image in pixels, next two positions are the origin and anchor which I don't care about for the moment and the final size is the scaled size in pixels.
var icon_scaled = new google.maps.MarkerImage(
img-filename,
new google.maps.Size(64, 64),
null,
null,
new google.maps.Size(scaled_size, scaled_size)
);
In the examples I found, you can omit the first size and let the browser calculate it. That works on Chrome but fails on Firefox with an error message like:
Error: IndexSizeError: Index or size is negative or
greater than the allowed amount
Fiddle here: http://jsfiddle.net/y8E54/
How can I do this on both browsers without any errors?
BTW: I know MarkerIcon is deprecated - my experiments replacing it using 'icon' as per the docs and specifying 'size' and 'scaledSize' lead to the same kinds of issues.
I had the same problem and after some research and a simple workaround, I was able to fix this headache.
Here is what I did.
It seems that you need to set both the "size" & "scaleSize" attributes for this to work in FF. But then, there was one other thing which bugged me. When I set the "size" attribute to the original size of the icon, the icon scaled but cropped abruptly without showing the full icon - probably because of the size limitation.
So, I set of the "size" attribute to the max limit of the scaled img (which was 64 in my case) and it worked like a charm.
cObject.setIcon({
url: cObjects[y].getIcon().url,
scaledSize: new google.maps.Size(icoSize, icoSize-1),
size:new google.maps.Size(64, 64)
});
I'm trying to place a text label next to a spin box in a horizontal layout. I want the label to be as small as possible, and the spin box as large as possible, so I set the label's horizontal sizing policy to Minimum and the spin box's horizontal sizing policy to Maximum. However, This results in the label having the maximum size and the spin box having the minimum size:
If I swap the sizing policies, I get what I want:
Is this backwards behavior a known bug, or am I just not understanding something about Qt layouts?
Using QtCreator 2.7.0 based on Qt 5.0.2 (32-bit) on 64-bit Windows 7.
"minimum" means that the widget must have the given size or more (the given size is a minimum), while "maximum" means that the given size is an upper limit, so the behaviour you observe is consitent with semantics.
I would set the spinbox policy to "expanding" and the label to "preferred".
I have an application with width/height of 100%. I have several nested groups within and their measurements are all not set, instead being defined as top=5 or left/right=10, etc.
I'm trying to get the actual with of a group that should be 390. I've set the swf object size to be 400 from the html embed code, and the group is inside another group that is width=100%. The group has a left=5 and right=5 so the width should be 400-10. When I display the .width and .measuredWidth of this group, the width is always 400.
I'm fairly new to flex/flash. Do I need to have explicitly set widths in order to get the width of child containers? Is there something I'm doing wrong here?
Thanks!
Percentage size of Component is calculated at parent's updateDisplayList(),so it's available only through width & height.
Methods getExplicitOrMeasuredWidth/Height() may return following:
Explicit width/height
Or
Measured width/height when mode is set to Wrap. This is calculated during Component's measure().
If you do not plan to override measure or updateDisplayList you simply should not use getExplicit... at all.
Use the getExplicitOrMeasuredWidth() method of the UIComponent. This returns the explicit width if set (e.g., width="700") or the measured width (in pixels) if not. If a percentage width is set, it returns the actual measured width.
It turns out there was an inner group with a path that was throwing the layout off. When I removed this element, the .width property worked as it had before.
One thing that surprised me is that .measuredWidth and getExplicitOrMeasuredWidth() both returned 10 when .width returned 390.
I believe that it's returning the right value. If you have an application A, width 400. Then you put group B inside it with width 100% and some padding. Group B really is 400, because it's extended all the way to the edges of the application. However, by giving it left/right/padding/whatever, it, in turn, can adjust its children so they aren't so close to the edges. You may need to look for the maximum width of group B's children to get what you want.
Update:
According to documentation:
http://livedocs.adobe.com/flex/3/html/help.html?content=size_position_5.html
Using constraint-based layouts overrides width and percentWidth. Try measuredWidth, though it may not be filled until the component has had time to go through its measure() phase during invalidation...