在下面Xamarin形式的代码,我试图对准入口图片为Bootstrap input group addon alignment problems与入口在Xamarin对齐图像格式
解释创造视觉外观像一个自举输入组,但它有以下缺点:
- 的图像需要更多的宽度和高度小于指定HeightRequest和WidthRequest
- 有图片和条目
如何解决这个问题?
XAML
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyHomeScreen2;assembly=MyHomeScreen2"
x:Class="MyHomeScreen2.InputFormTest"
NavigationPage.HasNavigationBar="False">
<ContentPage.Content>
<Grid x:Name="inputGrid" Grid.Row="1" ColumnSpacing="0" RowSpacing="0" Padding="0" BackgroundColor="#606060">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label x:Name="lblReading" TextColor="White" Text="READING" Grid.Row="0" Margin="15"></Label>
<StackLayout Grid.Row="1" Orientation="Horizontal">
<Image Source="homea.png" Aspect="AspectFit"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
HeightRequest="10" WidthRequest="20"
BackgroundColor="Silver" ></Image>
<Entry x:Name="myEntry" TextColor="Black" Text="1" Keyboard="Numeric" BackgroundColor="White"
Opacity="0.9" HeightRequest="20">
</Entry>
</StackLayout>
</Grid>
</ContentPage.Content>
</ContentPage>
你不能 “FillAndExpand” 的水平和垂直图像的选项。用“CenterAndExpand”覆盖它,并在Entry视图中放置“FillAndExpand”布局选项。 –
我没试过。但我确定问题在那里。让我看看我能否实现它,我会告诉你。 (对不起英语不好) –
1将水平和垂直选项更改为中心,开始或结束,以及2在Stacklayout上设置Spacing =“0” – Nick