1

ラベルを表示するxamlページと、グループ化オプションを使用したリストビューがあります。私が期待するように、ページ全体に表示される背景イメージがあります。しかし、このページはAndroidシミュレータでうまく動作します(画像の背景はページ全体に表示されます)が、iOSシミュレータではうまく動作しません。 iOSシミュレータでは、画像の背景が「History Facts」というテキストの上部ラベル要素の下に表示されますが、赤い枠内にマーク/塗りつぶされたListView領域には表示されません。白い背景は代わりにListViewの下に塗りつぶされます。添付のスクリーンショットをご覧ください。助けてください。ありがとう。ListViewで画像の背景が正しく表示されない

enter image description here

私のXAMLファイルのマークアップ:ブレイブハート続き

<?xml version="1.0" encoding="utf-8" ?> 
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:local="clr-namespace:Quiz;assembly=Quiz" 
      xmlns:converter="clr-namespace:Quiz.Converters;assembly=Quiz" 
      x:Class="Quiz.QuizResultPage"> 

    <ContentPage.Padding> 
    <OnPlatform x:TypeArguments="Thickness" iOS="10, 20, 10, 0" Android="10, 0" WinPhone="10, 0" /> 
    </ContentPage.Padding> 

    <ContentPage.Resources> 
    <ResourceDictionary> 
     <converter:BoolToStringConverter x:Key="boolToString" TrueText="Yes" FalseText="No" /> 
     <converter:BoolToColorConverter x:Key="boolToColor" TrueColor="Green" FalseColor="Red"/> 

     <Style TargetType="View" x:Key="labelBase"> 
     <Setter Property="HorizontalOptions" Value="Center"></Setter> 
     <Setter Property="VerticalOptions" Value="Center"></Setter> 
     </Style> 

     <Style TargetType="Label" x:Key="labelTopTitleStyle" BasedOn="{StaticResource labelBase}"> 
     <Setter Property="FontSize" Value="Large"></Setter>   
     </Style> 

     <Style TargetType="Label" x:Key="questionStyle"> 
     <Setter Property="FontFamily" Value="Courgette-Regular"></Setter> 
     <Setter Property="TextColor" Value="White"></Setter> 
     <Setter Property="FontAttributes" Value="Bold"></Setter> 
     <Setter Property="FontSize" Value="Medium"></Setter> 
     </Style> 

     <Style TargetType="Label" x:Key="labelTimerStyle" BasedOn="{x:StaticResource labelBase}"> 
     <Setter Property="TextColor" Value="Yellow"></Setter> 
     <Setter Property="FontAttributes" Value="Bold"></Setter> 
     <Setter Property="FontSize" Value="Medium"></Setter> 
     <Setter Property="BackgroundColor" Value="Olive"></Setter> 
     </Style> 

     <Style x:Key="styleAnswer" TargetType="Label"> 
     <Setter Property="FontFamily" Value="Courgette-Regular"></Setter> 
     <Setter Property="FontSize" Value="Large"></Setter> 
     </Style> 

    </ResourceDictionary> 
    </ContentPage.Resources> 


    <RelativeLayout Padding="0"> 
    <!-- Background --> 
    <Image x:Name="imgBG" 
     Aspect="AspectFill" 
     Opacity="0.2" 
     Source="{local:ImageResource Quiz.Images.bg8.jpg}" 
     RelativeLayout.WidthConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Width}" 
     RelativeLayout.HeightConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Height}"> 
    </Image> 

    <StackLayout RelativeLayout.WidthConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Width}" 
     RelativeLayout.HeightConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Height}" 
      Orientation="Vertical"> 

     <Label Text="History Facts" Style="{Binding Source={x:StaticResource labelTopTitleStyle}}" ></Label> 

     <ListView x:Name="listViewResultQuestions" BindingContext="{Binding}" ItemsSource="{Binding Questions}" 
      IsGroupingEnabled="True" 
      GroupDisplayBinding="{Binding Text}" 
      GroupShortNameBinding="{Binding ShortName}" 
      > 
     <ListView.RowHeight> 
      <OnPlatform x:TypeArguments="x:Int32" iOS="80" Android="80" WinPhone="90" /> 
     </ListView.RowHeight> 

     <ListView.GroupHeaderTemplate> 
      <DataTemplate> 
      <ViewCell> 
       <StackLayout BindingContext="{Binding}" VerticalOptions="FillAndExpand" Padding="5" 
          BackgroundColor="{Binding Path=IsAnswerValid, Converter={x:StaticResource boolToColor}}" Orientation="Horizontal"> 
       <Label Text="{Binding DisplayIndex, StringFormat='{0}. '}" Style="{StaticResource questionStyle}" LineBreakMode="NoWrap"/> 
       <Label Text="{Binding Text}" Style="{StaticResource questionStyle}"/> 
       </StackLayout> 
      </ViewCell> 
      </DataTemplate> 
     </ListView.GroupHeaderTemplate> 
     <ListView.ItemTemplate> 
      <DataTemplate> 
      <ViewCell> 
       <StackLayout BindingContext="{Binding}" Padding="20, 5, 5, 5" Orientation="Vertical"> 
       <Label Text="{Binding Text}" Style="{StaticResource styleAnswer}"/> 
       <Label Text="{Binding IsValid, StringFormat='Answer is correct: {0}', Converter={x:StaticResource boolToString}}" Style="{StaticResource styleAnswer}"/> 
       </StackLayout> 
      </ViewCell> 
      </DataTemplate> 
     </ListView.ItemTemplate> 
     </ListView> 

    </StackLayout> 

    </RelativeLayout> 

</ContentPage> 
+0

を解決するであるあなたは、リストビューの背景色を設定しようとしたことがあり透明に?私はiOSとはデフォルトで白いと思う。 – BraveHeart

+0

こんにちはBraveHeart。ご助力ありがとうございます。 ListViewの重要なプロパティセットが不足していました。あなたに続いて、私はそのプロパティセットを追加し、問題は解決されました。ありがとうございました。ところで、私はラベル要素のために、私はそのプロパティを設定する必要はないことを知らない。しかし、ListViewでは、そのプロパティを "Transparent"に設定して、iOSがそれに満足している必要があります。 –

+0

私はちょうど私が答えとして与えたコメントを書くので、質問は答えられるだろう:) – BraveHeart

答えて

1

iOSではリストビューをデフォルトとして白の背景色を持っているので、あなたが何をする必要があるか、すべては「透明」にBackgroundColorをを設定すると、これはあなたの問題

1

、私は「透明」にリストビューのBackgroundColorを設定する必要があるとの問題が解決されています。

関連する問題