Xamarin.Forms: Android picture renderer is basically useless - xamarin.forms

So, I am trying to achieve the effect as shown in this picture (regarding the party picture)
This is a snap shot from the iOS version of the app simply following this code:
<Image Source="{Binding picture}"/>
So, as you see, all thats needed to show this picture like this is one line of code (on iOS at least).
Cause this is what that will look like on Android:
So, youll see, it renderes it way too tiny, just inside a corner.
To get to (almost) the same results as on the iOS version, I have to alter the code like this:
<Image Source="{Binding picture}"
VerticalOptions="Start"
HorizontalOptions="StartAndExpand"
HeightRequest="171"/>
Giving it height values and so much more stuff, and in the end it still shows slight borders (about a pixel wide) and this is just a terrible solution.
What is the best way of showing the party image just the same as it is on the iOS version just on Android?
Why is Droid rendering the image tiner, not taking up all the space as iOS does?

There is an Aspect attribute inside Image. According to the official document, the default value of the Aspect attribute is AspectFit. You can auto-fill by setting the Aspect property to AspectFill. Here is the official document(https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.aspect?view=xamarin-forms)

Related

Why is the Xamarin linear progress bar cut in half when I set a corner radius on Android?

I am using the Syncfusion Xamarin ProgressBar with a corner radius (version 17.4.0.55):
<progressBar:SfLinearProgressBar
HeightRequest="16"
CornerRadius="16"
Progress="75"
ProgressColor="#FFffbe06"
TrackColor="#33ffbe06"
TrackHeight="16" />
On Android the corner radius applies to the middle of the bar in addition to the sides. It appears to cut the progress bar in two.
This problem does not exist on iOS.
I attempted to solve the issue by setting the SegmentCount to "1". But that did not solve the issue.
<progressBar:SfLinearProgressBar
...
SegmentCount="1" />
What do I need to update in my XAML to avoid the middle corner radius?
After review this using Syncfusion's example app, I discovered that there is a difference between running the app in Debug mode and Run mode. Here is an example of both modes:
The top image is in debug mode and you can see the little gap on it. The bottom one is in Run mode and it is a perfect progress bar.
Definitely is something that needs to be reported to Syncfusion as a bug.

Xamarins Forms UWP App Images on scaled display

I have a laptop with a 4k display. The display properties are set to 3840 X 2160 (Recommended) for the resolution and the scale factor is set to 250% again, the recommended value. I have images in my project scaled with the following suffixes:
.scale-100.png
.scale-150.png
.scale-200.png
.scale-250.png
.scale-300.png
.scale-350.png
.scale-400.png
based on the documentation I found.
When I run the app, the images show up huge and throw the rest of the display off. Below is a screen shot:
if I set the scale to 100% - everything is tiny, but the images are correct. Here is a screen shot.
any idea how to fix this?
Derive from official document.
UWP image file names can be suffixed with .scale-xxx before the file extension, where xxx is the percentage of scaling applied to the asset, e.g. myimage.scale-200.png. Images can then be referred to in code or XAML without the scale modifier, e.g. just myimage.png. The platform will select the nearest appropriate asset scale based on the display's current DPI.
From your screen, it looks get the correct scale image, but your image control has been scale, Please try to set Aspect property as Fill for image control.
set the size on platform specific
OnPlatform is used to set specific value for each platform. For example
<StackLayout>
<StackLayout.Margin>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="iOS" Value="0,20,0,0" />
<On Platform="Android, UWP" Value="0,0,0,0" />
</OnPlatform>
</StackLayout.Margin>
...
</StackLayout>
You could specific StackLayout margin for each platform like code above.

Xamarin forms: Image is not showing in perfect circle

I already posted a question regarding this issue, never get any solution. So posting the same question with more details and findings.
For the circle images, I am using Xam.Plugins.Forms.ImageCircle nuget package in my project, which is working fine in android and windows but showing an oval shape in IOS, screenshot adding below.
Added ImageCircleRenderer.Init(); in AppDelegate.cs.
xmlns namespace added:
xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"
<controls:CircleImage
HorizontalOptions="Start"
VerticalOptions="Start"
Margin="0,0,0,-5"
WidthRequest="50"
Aspect="AspectFill"
BorderColor="#1C7DB4"
BorderThickness="2"
HeightRequest="50" />
Now I updated the Xam.Plugins.Forms.ImageCircle to 2.0.2 and the resulted image is adding below:
Thanks in advance
It looks as if you are displaying the circles in a ListView, which has a fixed height of the cells per default. It seems as if your cells are simply not high enough to give the CircleImages the space they need. You have two options to overcome this:
Set the cells heigth to a fixed value that is high enough.
I don't know the exact value of the cells padding, so you'll have to experiment a bit. Maybe start off with something around 60
<ListView RowHeight="60" ...>
Set HasUnevenRows="true"
I believe that this will fix the rows height automagically, but it comes at costs: There may be a negative impact on layouting your view.
<ListView HasUnevenRows="true">

Meteor mobile-config.js launchScreens

I'm creating the splash images for my app but I've got some questions:
Can I create of all them at once? I've seen some repos for this but
there are not updated with new sizes (e.g 2048x1536)
Would be possible to use the same image for different sizes?
My phone is 1920x1080 but there is no splash screen size for that so it takes one and applies a disproportionate image. If I've got
text on it it looks really badly.
What happens with the rest of images when I build? Meteor removes the rest? Are located in resources/splash.
Could be possible to use a html with css page?
Thanks in advance!
Next time you should consider splitting your questions into independent posts.
Creating splash images: if your image is simple enough, indeed you have many scripts that can generate the different sizes automatically. I am sure you can customize them to fit your sizes.
Use the same image for different sizes: in general, that would mean your image will be stretched by the device to fill the screen. On Android, you can define a 9-patch PNG that will tell the device which pixels can be stretched, so that some part(s) of your image is not deformed.
Deformed image for 1920x1080 screen: depending on the pixel density, there should very probably be a placeholder for that.
Storage of image versions: by default, all versions (i.e. sizes) are packaged within your APK / APP, so that whatever the device needs will be available once user has downloaded the app.
Using an HTML+CSS page for splash screen: in general, no, but it depends on what you want to do with your splash screen. Meteor calls it "launch screen", because it is the first thing it displays while the app is loading / "launching". In particular, the WebView and local server may not be ready yet, and cannot serve any HTML/CSS. That is why you have to use a plain image, which is passed to a very simple activity while the app is loading. But some people also use a "waiting screen" between some parts of their app. In that case, your WebView and local server are already loaded, and you can simply use whatever you want.
Update:
For Android, if 9-patch PNG does not fit your need, you can also try to request Cordova's splashscreen plugin to maintain the aspect ratio of your image:
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/#preferences
<preference name="SplashMaintainAspectRatio" value="true" />
"SplashMaintainAspectRatio" preference is optional. If set to true, splash screen drawable is not stretched to fit screen, but instead simply "covers" the screen, like CSS "background-size:cover". This is very useful when splash screen images cannot be distorted in any way, for example when they contain scenery or text. This setting works best with images that have large margins (safe areas) that can be safely cropped on screens with different aspect ratios.
In Meteor, you would use App.setPreference in mobile-config.js:
App.setPreference("SplashMaintainAspectRatio", true, "android");

web app CSS trouble

I'm trying to present my notecards in a web app style.
I'm not worried about caching, or making it work offline.
I just want it render well in the iOS browser.
Here's the link: http://kaninepete.com/flashcard/review.php?Sec=3
I want it to look the same as if you re-size your browser window to 320x480.
The problem is, it always renders a huge amount of blank space off to the side.
I want to lock the scrolling to only the vertical axis (like flipping through notecards),
but also have the text at a readable size.
You can use CSS media queries to set your template on a certain width/height model. This works well and can adjust specifically for iPhone screens.
As for the font size issue you'll probably need to just spend time testing. With that it's going to require some type of virtual simulator or a real iPhone where you can test the site. I just loaded it up onto my iPhone 4 and I see what you mean about additional space - this is just because of your page size. Try messing with CSS media queries I think you'll find the answer in there.
Here is a very handy Google search to hopefully get you started on the right track. CSS3 has a lot of new features. Many of them geared towards mobile :)
Reading your question again, here's some suggestions based on what I think you're looking for.
Make sure your document is valid HTML before you continue. Safari on iOS supports HTML 5, so I'd suggest targeting that, unless your platform targets something different already.
If you just want it to run well in iOS Safari, then code for that. If you want it to look similarly in other browsers, however, then it may be necessary to look at styles targeting the iOS device (via width/height). See http://davidbcalhoun.com/2010/using-mobile-specific-html-css-javascript (It seems hacky, but based on some research a week ago, this still seems to be the suggested route.)
You've got CSS that shouldn't be in there if you want to target multiple browsers. overflow:hidden and set pixel widths.
Generally, I'd say you'll want to tweak your markup as well. List items or headers would be much better than just simple breaks.
Maybe I'm just oversimplifying the question, but it looks to me like all you really need to do is wrap each notecard in a div, perhaps giving each div a <div class="notecard_wrapper">. then just attach a stylesheet that specifies the width and height you want for each card.
This page explains Safari's viewport and how to change it. It will probably fix the font size problem and maybe help with the page size.
Basically, Safari by default simulates a screen that's about 900px wide, when it's actually about 300px (so the page appears zoomed out). This makes pages designed for real computers render properly, but for a web app you usually don't want it to zoom the page at all. The viewport tag should let you control that.

Resources