Reputation: 129
I try code below but the android preview does not work when using scroll view and ios preview work fine just does not show the images but when run the project the result in simulator and emulator is true, my problem is on the preview
this my xaml page:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage Style="{StaticResource baseStyle}" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:Flightio" x:Class="Flightio.MainPage"
xmlns:ffimageloadingSVG="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
xmlns:fftransformations="clr-namespace:FFImageLoading.Transformations;assembly=FFImageLoading.Transformations">
<ContentPage.Content>
<ScrollView>
<Grid RowSpacing="8" x:Name="grid_Main">
<Grid.RowDefinitions>
<RowDefinition Height="45" />
<RowDefinition Height="75" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="Logo.jpg" x:Name="image_logo" HorizontalOptions="Center" Margin="0,10,0,0"/>
<RelativeLayout HorizontalOptions="FillAndExpand" x:Name="relLay_blueMenu" BackgroundColor="#1e559e" Grid.Row="1" Margin="10,0,10,0">
<ContentView BackgroundColor="White" x:Name="view_domesticMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.8}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
<RelativeLayout x:Name="relLay_flightMenu" HorizontalOptions="FillAndExpand">
<Label Text="aliali" TextColor="Red" XAlign="Center" Margin="10,0,10,0"/>
</RelativeLayout>
</ContentView>
<ContentView BackgroundColor="#1e559e" x:Name="view_internationalFlightMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.6}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"></ContentView>
<ContentView BackgroundColor="#1e559e" x:Name="view_hotelMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.4}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"></ContentView>
<ContentView BackgroundColor="#1e559e" x:Name="view_trianMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"></ContentView>
<ContentView BackgroundColor="#1e559e" x:Name="view_busMenu"
Margin="0,5,0,0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
<Label Text="aliali2" TextColor="Blue" XAlign="Center"/>
</ContentView>
</RelativeLayout>
<!-- <ffimageloadingSVG:SvgCachedImage Source="baseline-flight.svg" x:Name="image_logo2" HorizontalOptions="Center" Grid.Row="2"/> -->
</Grid>
</ScrollView>
</ContentPage.Content>
</ContentPage>
and I got this error on android preview when using scroll view:
so I have two questions:
1- how to fix my android preview?
2- how show images in ios preview?
Upvotes: 0
Views: 856
Reputation: 378
I had the same problem and I solved it by changing the target platform of the Android project.
From Android 9.0 (Pie) to Android 8.1 (Oreo) in the application properties and in the Android manifest.
Upvotes: 0
Reputation: 15816
1- how to fix my android preview?
I just tested you xaml
code in my side and it works well in preview.
2- how show images in ios preview?
Try to remove the .jpg in image's name. For example:
<Image Source="Logo"/>
Also, check the tips listed here: xaml-previewer-isnt-showing-or-shows-an-error
but when run the project the result in simulator and emulator is true
I think the result in simulator and emulator is more reliable than in preview.
Upvotes: 1