Gerardo Tarragona
Gerardo Tarragona

Reputation: 1215

Entry height not working on xamarin forms

I want to set the height of the Entries showed on the next peace of code of a Xamarin.Forms project but it just doesn't work..

If I set the height of the row to something like: Height="1.3*", the Entry takes the whole height of the row but the placeholder won't be vertical aligned so I would like to use HieghtRequest instead.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage BackgroundColor="White">

<Grid BackgroundColor="Transparent" RowSpacing="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

    <Grid.RowDefinitions>
        <RowDefinition Height="5*" />
        <RowDefinition Height="4*" />
    </Grid.RowDefinitions>

    <Grid Grid.Row="0" VerticalOptions="FillAndExpand" HorizontalOptions="CenterAndExpand" Padding="0, 30, 0 ,0" RowSpacing="15">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>

        <Entry Grid.Row="0" Placeholder="{Binding emailAddress}" VerticalOptions="Center" HeightRequest="70" WidthRequest="330" BackgroundColor="Gray" TextColor="Black"  HorizontalOptions="CenterAndExpand"/>
        <Entry Grid.Row="1" Placeholder="{Binding password}" HeightRequest="300" VerticalOptions="Center" WidthRequest="330" IsPassword="true" BackgroundColor="Gray" TextColor="Black" HorizontalOptions="CenterAndExpand"/>

        <StackLayout Grid.Row="2">
        </StackLayout>

        <Button Grid.Row="4" BackgroundColor="Red" TextColor="White" HorizontalOptions="CenterAndExpand" Text="{Binding signIn}" HeightRequest="70" WidthRequest="330"/>

    </Grid>

    <Grid Grid.Row="1">
    </Grid>

</Grid>

Upvotes: 1

Views: 2785

Answers (1)

Renjith
Renjith

Reputation: 682

Entry Height is not working because you have given 1* as RowDefinition. You can set RowDefinition as Auto and set HeightRequest againt each controls as prefered. Also Use YAlign="Center" to vertically align the text. I hope this will help

Upvotes: 3

Related Questions