In my login UI, I have a footer image, which is showing perfectly in small devices. But on big screen devices (mainly on iPad) it is not showing fully.
I tried all Aspect property of Image, but not worked.
Screenshot:
I try a lot to fix this but didn't get a solution.
Attaching the LoginPage.xaml file with this question. Please suggest a solution for this issue. :)
Make sure (in the iOS project -> Assets) your image set has 3 different sizes xxx.png,xxx.png#2x and xxx.png#3x .
Which image will be used for your app? That depends on the device your app is viewed on. Higher resolution devices (larger and newer devices) have more pixels on their screens. Thus they need higher resolution images to display properly without any blurring.
If you don’t supply the higher resolution (#2x or #3x) images, your app will automatically try to scale the #1x image up. This is not good and can result in a distorted or blurry image!
Based on the file you linked in the comments, I think it would suffice to remove the bottom StackLayout wrapping the Image, and instead put Grid.Row="1" & VerticalOptions="End" to the bottom Image.
Please update your question with the relevant code to make the question and answers more helpful to others.
Remove latest StackLayout with image and add it after StackLayout with Grid.Row="1" like this
<Grid Grid.Row="1"
BackgroundColor="#c0eefb">
<Image
Source="ic_footer_image_xx.png"
Aspect="AspectFill"
HorizontalOptions="FillAndExpand"/>
</Grid>
Related
Is it good to use margin/padding to align the position of CachedImage in XAML Xamarin Forms? Or any other preferable/good way to align it so that it can stay consistant to all devices screens?
Like for example:
There are plenty of options, which to use will depend on the rest of your layout. Anyway, increasing the transparent area of the image will not port very well, because of different screen-sizes and -ratios.
Learn about layouts in Xamarin.Forms, it will help you much. On way to center (or otherways align) an image would be to use an AbsoluteLayout (see here)
<AbsoluteLayout HorizontalOptions="Fill" VerticalOptions="Fill">
<Image Source="whatever.png"
AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds=".5,.5,-1,-1" />
</AbsoluteLayout>
AbsoluteLayout.LayoutBounds=".5,.5,-1,-1" sets the position of the Image to centered, while the size is retained.
I am developing in Xamarin forms, and I have a Label that can contain a varying amount of text.
The platforms I use in forms are primarily: Android and UWP (no need for iOS ATM).
I want to give this label a background that is not rectangular and that is something more like this: (chat/message bubble style)
I have read about some possible solutions but I'm confused from all the options that are available.
From what I understand of my research around this and from my work with other platforms there are basically two options:
Set an image background.
Use Custom graphic controls to create the shape I want.
I'm not sure how to implement any of these options in Xamarin Forms, I'll be glad to get some help.
The easy solution would be to host the Label inside a View and set have an Image behind the label:
<Grid>
<Image Source="message_background.png">
<Label Text="{Binding Message}">
</Grid>
This is not very performant if you're going to have a lot of these on screen. The best solution would then be to use a custom renderer for each platform an implement it natively. This would give much better performance much more flexibility. It's more maintenance and initial work though.
You can read up on custom renderers here
I am using VS2013, Windows 8.1 and developing a windows store app.
Im creating a simple contacts - listview, that displays the contact details along with contact image within an ellipse. When I click on the listview item, I want to display the contact details on right side of the page. Now the issue I am facing is, I am not able to fit the contact image to the right size on the ellipse on the right side pane.
I am able to achieve it in my list view since its an smaller ellipse.
Important: I do not want the image to look stretched/Zoomed in /Zoomed out. It should exactly look like how it appears within the list view. (For list view , I have used Ellipse.Fill along with Imagebrush, but relatively smaller sized ellipse)
What I tried so far:
Ellipse.Fill property which paints the image to size, but the image looks stretched.
I tried setting "Stretch" property within the image tag within ellipse, but did not work.
I tried Image.clip, but I do not have "EllipseGeometry" option, instead only RectangleGeometry.
Lastly I created an image that has a transparent center and I place this frame over the contact image like a mask. This works well on some resolutions. But when some other resolution, the contact images which are binded from backend, go beyond the frame, although I set "MaxHeight" or "Height" properties.
I want to do it the right way, since I feel adding an image mask might not be a great way to achieve this. Please help!
I tried this for listview, n works fine, But the same code for right pane looks stretched (I have tried removing stretch attirbute, or tried other options like Stretch ="None" /"Uniform" etc )
I have attached screenshot.
Since code isn't clearly mentioned, you can do it with both Ellipse and Border. Here's the code snippet
<!--With Ellipse-->
<Ellipse Height="200"
Width="200">
<Ellipse.Fill>
<ImageBrush Stretch="Uniform"
ImageSource="Assets/profile.png" />
</Ellipse.Fill>
</Ellipse>
<!--With Border-->
<Border Height="200"
Width="200"
CornerRadius="150">
<Border.Background>
<ImageBrush Stretch="Uniform"
ImageSource="Assets/profile.png" />
</Border.Background>
</Border>
Here's the result
The properties "AlignmentX AlignmentY" within ImageBrush solved my issue.
If your image has portrait orientation, then you can use Stretch, AlignmentX, AlignmentY properties of ImageBrush like this to achieve best preview result
<Border CornerRadius="20" BorderThickness="1" BorderBrush="DarkGoldenrod">
<Ellipse Width="40" Height="40">
<Ellipse.Fill>
<ImageBrush ImageSource="{Binding PractitionerPhoto}" Stretch="UniformToFill" AlignmentX="Center" AlignmentY="Top" />
</Ellipse.Fill>
</Ellipse>
</Border>
In our WinRT app, we have provided image as a background to grid and buttons through XAML.
We observed that images taking long time to load, app showing only other text controls (like TextBlock) first, then after some duration, our images loaded. Till the time we only see text controls in page.
We are setting background as below
<ImageBrush ImageSource="ms-appx:////Images/image.png"/>
Please let me know, what can we do to resolve this issue.
Thanks.
You can
reduce the resolution of the image
wait for it to load before you show the page - either by starting that earlier somehow or by showing the page completely black and, say, fading in when the image loads
use a lower resolution image or other asset until the image loads
not use that image at all
I have a hunch that if the image source gets set early enough - WinRT will wait for a short time (a fraction of a second) before it shows a new page to give the image a chance to load before it starts running transition animations etc., so lowering the image resolution altogether or using a lower resolution before a higher resolution one loads is one approach.
one more option is to have a background be outside of the root frame - e.g. modify App.xaml.cs to have a grid as root visual and put the background image and the frame inside of it so you can change the image at any time.
This is a weird behaviour,
However you can try to opt for images with smaller size/resolution to optimize rendering time.
Also, try to set the background image in the Page's constructor - Since, Microsoft may(I am not sure though) handle XAML Parsing via Async Operations
Instead of ImageBrush try to use regular Image with CashMode property set to "BitmapCache":
<Grid>
<Image Source="ms-appx:////Images/image.png"
CacheMode="BitmapCache" />
<!-- Your other content above background image -->
</Grid>
I have an image as a drawing brush in xaml. The only property set is Stretch, which is set to Uniform.
The image is then set to the background of a usercontrol which has no properties set with regards to size.
The usercontrol is then used within a a grid, and set to span 2 rows like so:
<common:Logo
Height="130"
Width="500"
Grid.Column="0"
Grid.Row="0"
Grid.RowSpan="2"
HorizontalAlignment="Left"
/>
The problem is that there is loads of white space on top and below the image, which is also quite small.
The image started as a vector graphic and has no space above or below.
When I view the usercontrol with sizes set, it fits perfectly with no white space.
I am hoping this is not a problem with the grid reporting an incorrect size.
Any ideas would be appreciated!
Visual Studio was not refreshing any of the changes, running the code and reviewing what was produced fixed the whole problem!