I've been trying to create a simple splashscreen within a Xamarin Forms PCL project, which shows a single full image. The next view is my MainPage on Xamarin Forms, which has the same image with two buttons.
To properly fill the screen with the image without distort the image, I'm using an Image with AspectFill inside of a Relative Layout:
<Image
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height}"
Aspect = "AspectFill"
Source = "splash"
VerticalOptions = "FillAndExpand"/>
The AspectFill does exactly what I need:
"Scale the image to fill the view. Some parts may be clipped in order to fill the view."
In my IOS project I just draw the same launch screen and the image matches the MainPage image. Unfortunately, it doesn't happen on Android.
I guess what I need is an Android layout that looks like my MainView, but I couldn't write this the same way as "AspectFill" does ![:( :(]()
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/splashlogo"
android:gravity="fill_vertical|fill_horizontal"/>
</item>
</layer-list>
I know it's wrong because to fill the screen both vertical and horizontal distort the image, then it doesn't match the next image.
So, what happens is that my splashscreen on Android is distorted.
I've tried to use an ImageView instead of bitmap, like:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:gravity="fill" android:layout_gravity="center">
<ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/splashlogo" android:scaleType="fitXY" />
</RelativeLayout>
</LinearLayout>
But the only thing I see is a blank screen in the splashscreen and I don't know why.
Does anybody has a solution for this?