私は、デバイスサイズに応じて単独でしか使用できない背景をグリッドに挿入する必要があります。 私は1000の組み合わせを試しましたが、小さいままであるか、またはすべてに適合しません。 下の画像では、下の画面の後半にあるグリッド、グリッドに適応しなければならない画像の赤い丸で囲んだ部分を見ることができます。Xamarinの書式でサイズに合った背景画像を挿入します。pcl
私は、グリッド内の画像を入れしようとしているが、画像は、xを持っている:私は後半のグリッド全体に適応しなければならない対象が何であるかを名=「backgroundImageのを」、画面、どうすればいいですか?ここでのコードは次のとおりです。
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Fimap.Login"
BackgroundColor="#333">
<ContentPage.Padding>
<OnPlatform x:TypeArguments="Thickness"
iOS="0,0,0,0"
Android="0,0,0,0"
WinPhone="0,0,0,0" />
</ContentPage.Padding>
<ContentPage.Content>
<ScrollView>
<StackLayout VerticalOptions="Center" HorizontalOptions="CenterAndExpand" Orientation="Vertical" Spacing="0">
<ActivityIndicator x:Name="loadingBeforeLogin" IsVisible="true" Color="#008ECC" IsRunning="true" />
</StackLayout>
<RelativeLayout VerticalOptions="Center" HorizontalOptions="CenterAndExpand" x:Name="allContent">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="5*"></RowDefinition>
<RowDefinition Height="5*"></RowDefinition>
</Grid.RowDefinitions>
<!-- immagini loghi e scritta login sopra-->
<Grid Grid.Row="0" BackgroundColor="#1f2429">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="6*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions Height="*">
<RowDefinition Height="2*"></RowDefinition>
<RowDefinition Height="6*"></RowDefinition>
</Grid.RowDefinitions>
<Image Aspect="AspectFit" x:Name="logoScritta" Grid.Row="0" Grid.Column="1" Source="Images/fimaLogoLogin.png"></Image>
<Image Aspect="AspectFit" x:Name="logo" Grid.Row="1" Grid.Column="1" Source="Images/logo.png"></Image>
<Label TextColor="#fff" Grid.Row="2" FontSize="22" Grid.Column="1" Text="Login" />
</Grid>
<!-- username e password input e ricorda password -->
<Grid Grid.Row="1">
<Image x:Name="backgroundImage"/>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="6*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
</Grid.RowDefinitions>
<ActivityIndicator x:Name="loading" Grid.Row="0" Grid.Column="1" IsVisible="false" Color="#008ECC" IsRunning="true" />
<Label TextColor="#2196F3" Grid.Row="1" Grid.Column="1" Text="" />
<Entry TextColor="#2196F3" PlaceholderColor="#A9D6FA" FontSize="24" Grid.Row="1" Grid.Column="1" Placeholder="Username" x:Name="UsernameEntry" Text="" />
<Label TextColor="#2196F3" Grid.Row="2" Grid.Column="1" Text="" />
<Entry TextColor="#2196F3" PlaceholderColor="#A9D6FA" FontSize="24" Grid.Row="2" Grid.Column="1" Placeholder="Password" IsPassword="True" x:Name="PasswordEntry" Text="" />
<Button x:Name="LoginButton" FontSize="22" Grid.Row="3" Grid.Column="1" Text="Accedi" Clicked="Login_OnClicked"/>
<Grid Grid.Row="4" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="1*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="7*"></ColumnDefinition>
<ColumnDefinition Width="3*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label TextColor="#2196F3" Text="Ricorda accesso" Grid.Row="0" Grid.Column="0"></Label>
<Switch x:Name="switchRememberPassword" Grid.Row="0" Grid.Column="1"></Switch>
</Grid>
<Label x:Name="recuperaPassword" Grid.Row="5" Grid.Column="1" TextColor="#2196F3" Text="Hai dimenticato la password?" FontSize="12"></Label>
</Grid>
</Grid>
</RelativeLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>
SOLUTION アプリのコンストラクタを呼び出す前に名前相対
iOSのプロジェクトでImage backgroundImage = new Image();
backgroundImage.Source = "loginBackground.png";
backgroundImage.Aspect = Aspect.AspectFill;
relative.Children.Add(backgroundImage,
Constraint.RelativeToParent((parent) =>
{
backgroundImage.WidthRequest = parent.Width;
return 0;
}),
Constraint.RelativeToParent((parent) =>
{
return parent.Height - backgroundImage.Height;
})
);
何度も何度も同じ話題について同じ質問を作成していない、より多くの情報を提供するために、あなたの質問を編集してください。 –
[中心画像内の相対的なイメージを複製し、下部のxamarinフォームにアライメントする]可能性があります(http://stackoverflow.com/questions/41243604/center-image-inside-relativelayout-and-align-to-bottom-xamarin-forms) –
いくつかの質問がお互いにありますが、同じ例がありますが、さまざまな要求があります。私は学び、いくつかの例が必要です。 –