编辑器文字未在Android 5中显示

时间:2018-07-05 05:06:01

标签: xamarin xamarin.forms xamarin.android

我正在Visual Studio 2017中使用Xamarin Forms应用程序,我想使用带有滚动显示的Editor控件显示长文本说明,我实现了以下代码,并且在Andoroid 7和Iphone设备上运行良好。但是,Android 5设备中没有Text,但可以滚动。

xaml代码

 <Grid BackgroundColor="#0B738C">
        <Grid.ColumnDefinitions>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="25"></RowDefinition>
            <!--bg-->
            <RowDefinition Height="20"></RowDefinition>
            <!--brand-->
            <RowDefinition Height="30"></RowDefinition>
            <!--Lable Agreement-->
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="40"></RowDefinition>
            <!--Text Agreement-->

            <!--checkox-->
            <RowDefinition Height="50"></RowDefinition>
            <!--I agree Button-->
            <RowDefinition Height="25"></RowDefinition>
        </Grid.RowDefinitions>

        <Image 
            Grid.Row="0" 
            Grid.Column="0" 
            Source="{local:ImageResource bg.jpg}" 
            Aspect="Fill" 
            Grid.ColumnSpan="1" Grid.RowSpan="12" x:Name="bgImage" />

        <Image 
            Grid.Row="1" 
            Grid.Column="0" 
            Source="{local:ImageResource brand.png}" 
            Aspect="Fill" 
            Scale="1.5"
            HorizontalOptions="Center"
            VerticalOptions="Center"
            Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="imageBrand" >
        </Image>

        <Label 
            x:Name="labelAgreement"
            IsVisible="True"
            Grid.Row="2" 
            Grid.Column="0" 
            Grid.RowSpan="2"
            HorizontalOptions="Center"
            Text="Software License and Agreement"
            TextColor="WhiteSmoke"
            FontFamily="Open Sans"
            Margin="10"
            FontSize="16" />

        <ScrollView Grid.Row="3" Grid.Column="0" IsVisible="True" >
            <StackLayout>
                <Editor x:Name="txtAgreement" TextChanged="HandleAgreemnetContent_TextChange" IsEnabled="False"  Margin="20,0,20,5" FontSize="12"  BackgroundColor="White" HeightRequest="900" WidthRequest="300" />
            </StackLayout>
        </ScrollView>

        <Switch  

            x:Name="checkAgree"
            Scale="0.70"
            Grid.Row="4" Grid.Column="0" 
            Margin="15,0,10,5"
            HorizontalOptions="Start"
            Toggled="Handle_Toggled"></Switch>

        <Label      
            Grid.Row="4" Grid.Column="0" 
            HorizontalTextAlignment="Start"  
            VerticalTextAlignment="Center"
            HorizontalOptions="Start"
            TextColor="#FFFFFF"
            FontFamily="Open Sans"
            FontSize="14" 
            FontAttributes="Bold"
            Text="Agree to the above terms and conditions" 
            Margin="80,0,0,10"/>



        <Button 
            Margin="0,0,0,0"
            Grid.Row="5"
            Grid.Column="0"
            x:Name="buttonAgree"
            Text="Continue"
            HorizontalOptions="Center"
            VerticalOptions="CenterAndExpand"
            IsVisible="True"
            BackgroundColor="#1B9170"
            TextColor="#FFFFFF"
            FontFamily="Open Sans"
            FontSize="18"
            FontAttributes="Bold"
            WidthRequest="140"
            IsEnabled="False"
            Clicked="HandleAgree_Clicked"/>

        <Label 
            Grid.Row="5" 
            Grid.Column="0" 
            x:Name="labelError"
            Text=""
            Font="Large"
            HorizontalOptions="Center"
            VerticalOptions="CenterAndExpand"
            IsVisible="false"/>

    </Grid>

1 个答案:

答案 0 :(得分:0)

请您像下面的代码片段一样更改背景颜色。

<Editor>
                <Editor.BackgroundColor>
                    <OnPlatform x:TypeArguments="x:Color">
                        <On Platform="iOS" Value="#a4eaff" />
                        <On Platform="Android, UWP" Value="#2c3e50" />
                    </OnPlatform>
                </Editor.BackgroundColor>
            </Editor>