由于某种原因,我的按钮没有显示,我希望底部是绿色的底部,但它不是。也是他们的任何类型的编辑器,用于网格和控件的放置将使这变得更容易。
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="WellbeingNinja.Views.RunningPage">
<ContentPage.Content>
<Grid Padding="30,40,40,10">
<Grid.RowDefinitions>
<RowDefinition Height="200" />
<RowDefinition Height="200" />
<RowDefinition Height="200" />
<RowDefinition Height="200" />
<RowDefinition Height="200" />
<RowDefinition Height="200" />
<RowDefinition Height="200" />
<RowDefinition Height="200" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<Label x:Name="lblduration" Text="Duration"></Label>
</StackLayout>
<Frame Grid.Column="0" Grid.Row="0" x:Name="frameTotalSpeed" VerticalOptions="StartAndExpand" CornerRadius="2" >
<StackLayout>
<Label x:Name="lblSpeedText" Text="Speed(miles)"></Label>
<Label x:Name="lblSpeed" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="0.00" FontSize="Large" ></Label>
</StackLayout>
</Frame>
<Frame Grid.Column="1" x:Name="frameTotaldistance" VerticalOptions="StartAndExpand" CornerRadius="2" >
<StackLayout>
<Label x:Name="lblDistance" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="0.00" FontSize="Large" ></Label>
<Label x:Name="lbldistanceText" Text="Dist" HorizontalOptions="Center"></Label>
</StackLayout>
</Frame>
<Frame Grid.Column="0" x:Name="frmTotalMilesLeft" Grid.Row="1" VerticalOptions="StartAndExpand">
<StackLayout>
<Label x:Name="lblDistanceLeft" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="0.00" FontSize="Large" ></Label>
<Label x:Name="lblavgPace" Text="Avg Pace (Min/Mil)"></Label>
</StackLayout>
</Frame>
<Frame Grid.Column="1" Grid.Row="1" x:Name="frmTotalCarolesBurned" VerticalOptions="StartAndExpand">
<StackLayout>
<Label x:Name="lblTotalCalories" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="0.00" FontSize="Large" ></Label>
<Label x:Name="lblTotalCaloriesBurned" HorizontalOptions="Center" Text="Calories Burned"></Label>
</StackLayout>
</Frame>
<Button Grid.ColumnSpan="2" Grid.Row="3" Text="Start Workout"></Button>
</Grid>
</ContentPage.Content>
发布于 2020-04-13 06:10:25
如果你给每一行一个固定的高度200,那么第三行的Y位置是从600开始的,它可能会比屏幕的高度大。您在第3行添加了Button,但它超出了屏幕的范围。那么你就不会在屏幕上看到它了。
使用Auto会更好,它会自动调整大小以适合行或列中的内容。您还可以设置ColumnSpacing和RowSpacing,以便在行和列空间之间添加一些空格:
<Grid Padding="30,40,40,10" ColumnSpacing="30" RowSpacing="70">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60*" />
<ColumnDefinition Width="60*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
请阅读有关Grid的文档以获取更多信息,您也可以使用StackLayout来实现UI。
https://stackoverflow.com/questions/61177680
复制