进入高度不适用于xamarin表格

时间:2017-05-04 00:35:43

标签: xamarin xamarin.ios xamarin.android xamarin.forms

我想设置在Xamarin.Forms项目的下一代代码上显示的条目的高度,但它只是不起作用..

如果我将行的高度设置为:Height="1.3*",则条目占据行的整个高度,但占位符不会垂直对齐,所以我想使用HieghtRequest代替。

<?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>

1 个答案:

答案 0 :(得分:2)

条目高度不起作用,因为您已将1 *作为RowDefinition。您可以将RowDefinition设置为Auto,并将每个控件的HeightRequest设置为首选。 也可以使用YAlign =&#34; Center&#34;垂直对齐文本。我希望这会有所帮助