xamarin.forms - Stacklayout 中的 Xamarin.Forms 输入字段在 iOS 中被截断,但在 Android 中不被截断
问题描述
我有一个包含许多 ViewCells 的 TableView。每个 ViewCell 都是 Label 和 Entry 字段的 StackLayout。在 Android 上,一切看起来都很好。在 iOS 上,任何具有字段的 ViewCell 都具有字段值截止值(即仅显示第一个字符,然后显示几个点)。选择器工作得很好顺便说一句。我已经尝试了不同的 MinimumWidthRequest 到一个高值、不同的 HorizontalOptions、OnAppearing() 中的 ForceLayout() 等。我怎样才能让这些字段扩展到必要的最小值,以显示完整的值?
<TableView>
<TableSection x:Name="tblSingleCourse">
<ViewCell IsEnabled="True">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="Course Name:" />
<Entry x:Name="txtCourseTitle" HorizontalOptions="Center"/>
</StackLayout>
</ViewCell>
<ViewCell IsEnabled="True">
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Label Text="Start Date:" />
<DatePicker x:Name="dpStartDate" Format="D"></DatePicker>
</StackLayout>
</ViewCell>
</TableSection>
</TableView>
解决方案
尝试这个
<Grid Margin="10" RowSpacing="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Label Text="Course Name:" FontAttributes="Bold" Grid.Column="0" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
<Entry Grid.Column="1" PlaceholderColor="LightBlue" Placeholder="Enter Course name" x:Name="txtCourseTitle" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
</Grid>
<Grid Grid.Row="1" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="7*"/>
</Grid.ColumnDefinitions>
<Label Text="Start Date:" FontAttributes="Bold" Grid.Column="0" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
<Entry Grid.Column="1" PlaceholderColor="LightBlue" Placeholder="Enter StartDate" x:Name="dpStartDate" HorizontalOptions="StartAndExpand" VerticalOptions="Center"/>
</Grid>
<Button CornerRadius="7" HorizontalOptions="FillAndExpand" Margin="20,0,20,0" Grid.Row="2" Text="Discard changes" FontSize="Small" TextColor="White" BackgroundColor="PaleVioletRed"></Button>
<Button CornerRadius="7" HorizontalOptions="FillAndExpand" Margin="20,0,20,0" Grid.Row="3" Text="Save changes" FontSize="Small" TextColor="White" BackgroundColor="PaleVioletRed"></Button>
</Grid>
推荐阅读
- database - 在 oracle 上授予用户
- javascript - Nuxt.js 上的部署问题
- redis - 为什么会出现redis pub read io timeout?
- r - 数据框 1 中的参考坐标列填充数据框 2 中的起点和目标坐标
- python - Python中整数整除的限制
- javascript - 在 Typescript 中找到将已知格式的字符串解析为对象数组的最有效方法
- c++ - Linux Ubuntu-/usr/bin/ld: 找不到 -lbz2
- r - 用户定义的 S3 组通用函数如何在 R 中工作?
- node.js - 如何在服务器端 ExpressJs 上更改密钥名称 API
- excel - 动态平均前 9 个整数中的最低 4 个