Hello I'm developing a Xamarin.Forms application.
I have this code and the image fits to page on simulator.
How can I display the image in its original size?
var image = new Image { Aspect = Aspect.AspectFit};
image.Source = "image2.png";
Content = image;
To set the dimensions of an image you can't use the Width and Height properties. Because the Width and Height properties are read-only (as the error said).
Try to use the WidthRequest and HeightRequest properties to set your desired dimension.
Infos from Xamarin-Developer-Page:
WidthRequest does not immediately change the Bounds of a
VisualElement, however setting the WidthRequest will change the result
of calls to GetSizeRequest, which will in turn modify the final size
the element receives during a layout cycle.
Related
I want to get an icon from system and show it in Gtk.Image but in a spesific size.
Gtk.Image.icon_size property is an enum, it isn't setting pixel width or height. (Gtk.IconSize)
This is how I get icon from system theme:
var icon = new Gtk.Image.from_icon_name("icon_name", 0);
...
// Something like `icon.set_size(150, 150);` ?
But even it is a .svg file in .icons folder, it is displaying as too small like 16x16.
I want to display it like 150x150.
Thanks!
Set the (poorly named) pixel size
var icon = new Gtk.Image.from_icon_name("icon_name", DIALOG);
// Just use anthing here ^^^^^^^
icon.pixel_size = 150
Here is how I've solved:
// 150 is pixel size:
var icon_theme = IconTheme.get_default();
var pixbuf_icon = icon_theme.load_icon("icon-name", 150, IconLookupFlags.FORCE_SVG);
var final_img = new Image.from_pixbuf(pixbuf_icon);
// Use final_img...
Can I change the image size without losing quality.
I have set the custom size Width and Height to (1100,1100) as below then I get the image blurry.
Bitmap bitmap = new Bitmap("image.jpg");
System.Drawing.Image img = new Bitmap(bitmap,new System.Drawing.Size(1100,1100));
img.Save("output.jpg");
I'm new to animation with Xamarin Forms, I have a frame that I need to place it outside the screen like this:
The small frame is outside the device's screen
The small frame now inside the device screen
My problem is I need to know how I can place the frame like that (outside the screen) from the start, and how to know the width and the height of every device so I can use the TranslateTo() method to translate the frame to the exact same position for every device.
Thanks in advance
You can try this from your .cs page
Application.Current.MainPage.Width
Application.Current.MainPage.Height
You can use Xamarin.Essentials NuGet pakage to achieve this. And there is a useful class DeviceDisplay in there that should be helpful for you.
The documentation can be found here.
Usage example:
// Get Metrics
var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
// Orientation (Landscape, Portrait, Square, Unknown)
var orientation = mainDisplayInfo.Orientation;
// Rotation (0, 90, 180, 270)
var rotation = mainDisplayInfo.Rotation;
// Width (in pixels)
var width = mainDisplayInfo.Width;
// Height (in pixels)
var height = mainDisplayInfo.Height;
// Screen density
var density = mainDisplayInfo.Density;
I am new to webix and have a problem with ui.window!
For me the window never adjusts to the parent HTML element. :(
I want the window to have the same width and height as the parent (100%).
What am I dowing wrong?
See code in Webix Snippets: http://webix.com/snippet/c5fe5e96
According to the documentation:
"Window Sizing and Positioning
The must-have parameters for the window are width and height. If you don't set [them], the window [...] will occupy the whole screen."
http://docs.webix.com/desktop__window.html
"adjust - adjusts the component to the size of the parent html container"
http://docs.webix.com/api__link__ui.popup_adjust.html
Window and Popup widgets are working for the whole app, they are not using container and can't use .adjust as well.
You can size the Window to the document by using fullscreen option
var popup = webix.ui({
view: "window",
fullscreen:true,
http://webix.com/snippet/93a5e3ba
or by using the complex position property
var popup = webix.ui({
view: "window",
position:function(state){
state.left = state.top = 10;
state.width = state.maxWidth - 20;
state.height = state.maxHeight-20;
},
http://webix.com/snippet/164a3955
I have managed to make the window inherit the size of the HTML container by getting the HTML container size by using getNode() and then using setPosition, config.width, config.height and resize().
See example below.
http://webix.com/snippet/056b9610
I have written the following code to add image as a background to the BlackBerry screen.The image size is 320*240.The image is added to the screen but then I want to increase its height and width according to the size of the BB screen height and width.
Following is the code I have written:
Bitmap xtclogoBitmap = Bitmap.getBitmapResource("launch_xtc.jpg");
BitmapField xtcbitmapField = new BitmapField(xtclogoBitmap,Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH);
add(xtcbitmapField);
How can I increase the height and width of the image as per the BB screen size?
Bitmap img=Bitmap.getBitmapResource("3.jpg");
Bitmap bg = new Bitmap(Display.getWidth(), Display.getHeight());
img.scaleInto(bg,Bitmap.FILTER_LANCZOS, Bitmap.SCALE_TO_FILL);
you can replace Bitmap.SCALE_TO_FILL and/or modify the values of getheight and width by addition for example depending on your needs, then just add the bg
check this explanation from BlackBerry here
regards,