3
votes

I m working on a Xamarin Forms project using Visual studio 2017.I need to show long text using scrolling , so i implemented following code but it not show the all content it shows part of the content and not scrolling as well ,only shows text within the height of the lable .This is not working for both Android and IOS .If i remove HeightRequest="350" it's scrolling but , content is not showing

<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" >
        <StackLayout >
            <Label             
        x:Name="txtAgreement"
        HorizontalOptions="Center"
        VerticalOptions="Fill"
        HorizontalTextAlignment="Start"
        WidthRequest="300"
        HeightRequest="350"
        TextColor="Black"
        FontFamily="Open Sans"
        FontSize="10"
        FontAttributes="None"
        BackgroundColor="White"
        IsVisible="True"/>
        </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
Whats the rest of the xaml (mainly the grid that holds it) - TheGeneral
I updated the question - charitht99 perera

1 Answers

0
votes

you need to give the HeightRequest to ScrollView.

    <ScrollView Grid.Row="3" Grid.Column="0" HeightRequest="250">
    <StackLayout >
        <Label             
    x:Name="txtAgreement"
    HorizontalOptions="Center"
    VerticalOptions="Fill"
    HorizontalTextAlignment="Start"
    WidthRequest="300"
    HeightRequest="350"
    TextColor="Black"
    FontFamily="Open Sans"
    FontSize="10"
    FontAttributes="None"
    BackgroundColor="White"
    IsVisible="True"/>
    </StackLayout>
</ScrollView>