小编Ale*_*vic的帖子

网格行内的 Xamarin.Forms 标签的文本被切断

位于固定大小网格行中的 Xamarin.Forms 标签的文本被截断,或者更确切地说,它显示了太多文本,并且由于网格行的固定高度,最低行仅显示一半。网格行高必须保持固定。

gridInner.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.8, GridUnitType.Star) });
gridInner.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(7.5, GridUnitType.Star) });
gridInner.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1.7, GridUnitType.Star) });

var descLabel = new Label()
{
    HorizontalOptions = LayoutOptions.StartAndExpand,
    VerticalOptions = LayoutOptions.Fill,
    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
    FontAttributes = FontAttributes.None,
    TextColor = Color.Black,
    LineBreakMode = LineBreakMode.WordWrap,
    VerticalTextAlignment = TextAlignment.Start
};
descLabel.SetBinding(Label.TextProperty, "Offer.Description");
gridInner.Children.Add(descLabel, 0, 1);
Run Code Online (Sandbox Code Playgroud)

文字在 Android 5.1(Lollipop) 上被截断

在我看来,标签的高度大于网格行的高度,或者文本行高度计算错误。我已经尝试了所有我能想到的方法,例如:

<style name="App_TextViewStyle" parent="@android:style/Widget.TextView">
   <item name="android:baselineAligned">false</item>
   <item name="android:includeFontPadding">false</item>
   <item name="android:padding">1dp</item>
</style>
Run Code Online (Sandbox Code Playgroud)

任何在 XF 方面更有经验的人都可以对我有所了解吗?

grid android label xamarin xamarin.forms

6
推荐指数
1
解决办法
4352
查看次数

标签 统计

android ×1

grid ×1

label ×1

xamarin ×1

xamarin.forms ×1