我以 .xaml 形式設計了一個 UI: 我希望使用 ScrollView 獲得這樣的結果
但是當我應用ScrollView時,UI變成了這樣: 當我應用ScrollView UI改變時,我想從logo中洗掉上下不必要的空間
這是 xaml 代碼:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="App2.Views.AboutPage">
<ContentPage.Content>
<ScrollView>
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackLayout Grid.Row="0" Grid.Column="1" VerticalOptions="Start" HorizontalOptions="Center">
<Image Source="easypaisa1.png"/>
</StackLayout>
<StackLayout Grid.Row="1" Grid.ColumnSpan="3" VerticalOptions="Start" Margin="0,-150,0,0">
<Label Text="Account#" HorizontalOptions="Center"/>
<Label Text="1234567890" TextColor="Black" FontAttributes="Bold" FontSize="Title" HorizontalOptions="Center"/>
<Label Text="Account Title" HorizontalOptions="Center"/>
<Label Text="USER NAME" TextColor="Black" FontAttributes="Bold" FontSize="Title" HorizontalOptions="Center"/>
<Entry IsEnabled="False" Grid.ColumnSpan="3" Keyboard="Default" Text="Selected Package" FontAttributes="Bold" PlaceholderColor="#30769f" FontSize="14" TextColor="Black" Margin="20,10,20,0" />
<Entry Grid.ColumnSpan="3" Keyboard="Default" Placeholder="Transaction ID" PlaceholderColor="#30769f" FontSize="14" TextColor="Black" Margin="20,0,20,0" />
<DatePicker Margin="20,0,20,0" TextColor="#30769f"/>
<Entry Grid.ColumnSpan="3" Keyboard="Default" Placeholder="Transactor Name" PlaceholderColor="#30769f" FontSize="14" TextColor="Black" Margin="20,0,20,0" />
<Label Text="After payment from your easypaisa or other wallet account note Transaction ID, Transaction Date and enter your name in Transactor field." Grid.ColumnSpan="3" Margin="20,0,20,0"/>
<Button x:Name="DList" Text="Click to submit" Margin="20,0,20,0" CornerRadius="15" BackgroundColor="#212121" TextColor="White" HeightRequest="50" Padding="10,0,20,0"/>
</StackLayout>
</Grid>
</ScrollView>
</ContentPage.Content>
</ContentPage>```
Thanks Advance!
uj5u.com熱心網友回復:
這里我們需要absolute height在第一行設定a,讓它知道應該占用多少空間。
我們可以設定HeightRequest在 firstRowDefinition或 firstStackLayout或Imageself 上。
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
<StackLayout Grid.Row="0" Grid.Column="1" HeightRequest="100"/>
<Image Source="dog.png" HeightRequest="100"/>
PS:
auto僅適用于某些特定控制元件,例如 Label ..
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/459768.html
