Cof*_*fee 1 c# xaml xamarin.forms
我正在尝试创建一个旁边有条目的标签,我正在尝试实现下面的效果(我的条目的边框设置为透明,这就是它下面没有线条的原因):
\n\n\n\n当条目文本和标签文本都对齐时,随着输入更多数字,条目应该向左“增长”,并将“\xc2\xa3”符号向左移动,这是迄今为止我能做的最好的事情尽管:
\n\n\n\n这是使用代码:
\n\n<StackLayout Orientation="Horizontal" Grid.Row="0" Grid.Column="1">\n <Label HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand" Text="\xc2\xa3" FontSize="20" FontFamily="{StaticResource RobotoLight}" TextColor="#C7C7C7" Grid.Column="0"/>\n <controls:BorderlessEntry Text="{Binding Income.MonthlyIncome}" WidthRequest="80" HorizontalOptions="EndAndExpand" PlaceholderColor="#C7C7C7" Placeholder="0" VerticalOptions="CenterAndExpand" FontSize="20" FontFamily="{StaticResource RobotoLight}" TextColor="#C7C7C7" Grid.Column="1"/>\n </StackLayout>\nRun Code Online (Sandbox Code Playgroud)\n\n但是,尽管两者都居中,但条目文本略高于标签文本,我也无法弄清楚如何使条目根据文本扩展宽度,或者如何将其向右对齐(或堆栈布局端)。
\n\n我知道我在这里将 3 个问题捆绑在一起,所以如果有人能帮助解决其中的 1 个问题,那将是一个很大的帮助。
\n我使用简单的 Entry 和 Label 进行测试,您可以使用HorizontalOptions属性并设置为EndAndExpand 或End以使标签和 Entry 正确对齐,如下所示:
\n\n<StackLayout Orientation="Horizontal">\n <Grid>\n <Grid.ColumnDefinitions>\n <ColumnDefinition Width="*" />\n <ColumnDefinition Width="*" />\n </Grid.ColumnDefinitions>\n\n </Grid>\n <StackLayout Grid.Column="0" VerticalOptions="Start" HeightRequest="60">\n <Label Text="Monthly Income" VerticalOptions="CenterAndExpand"></Label>\n </StackLayout>\n\n <StackLayout Grid.Column="1" Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="Start" HeightRequest="60" >\n <Label HorizontalOptions="EndAndExpand" VerticalOptions="Center" Text="\xc2\xa3" FontSize="20" TextColor="#C7C7C7" />\n <Entry PlaceholderColor="#C7C7C7" HorizontalOptions="End" WidthRequest="100" VerticalOptions="Center" FontSize="18" TextColor="#C7C7C7" />\n </StackLayout>\n\n</StackLayout>\nRun Code Online (Sandbox Code Playgroud)\n\n效果如下:
\n\n\n\n并使条目自动调整宽度,也许您应该使用自定义渲染器来实现它
\n