我在应用程序中有此页面,我需要将一些编辑器组件放置在特定位置和特定位置。但是,当我设置一个小的 HeightRequest 时,编辑器不会在 android 上正确显示文本。
我尝试调整 FontSize 和 Margin 以正确显示它,但它们似乎都没有任何效果。
以下是两个 iOS 的屏幕:和安卓: .
我应该怎么做才能对 Android 产生预期的效果?
编辑:
我说的是上面写着“Formação Acadêmica”的部分
我设置了HeightRequest,但我想因为它是一个小的HeightRequest,文本在android中被截断。
这是创建该部分的代码:
Editor editor = new Editor();
if (atributo.tipo.Equals(Atributo.NUMERICO) || atributo.tipo.Equals(Atributo.INTEGER)) {
editor.Keyboard = Keyboard.Numeric;
}
if (atributoDoc.valor != null) {
editor.Text = atributoDoc.valor;
}
//(...)
editor.SetBinding(IsEnabledProperty, "IsEnabled");
editor.BindingContext = container;
editor.BackgroundColor = Color.FromRgba(1, 1, 0, 0.4);
editor.WidthRequest = atributoDoc.largura * ratio;
editor.HeightRequest = atributoDoc.altura * ratio;
editor.FontSize = editor.FontSize * ratio;
Frame frame = new Frame();
frame.AnchorX = frame.AnchorY = 0;
frame.OutlineColor = Color.Black;
frame.Padding = 0;
frame.Content = editor;
frame.HasShadow = false;
Device.BeginInvokeOnMainThread(() => {
container.Children.Add(frame, Constraint.Constant(atributoDoc.posicaoX * ratio), Constraint.Constant(atributoDoc.posicaoY * ratio + contImage.Y));
});
最佳答案
你必须写 customerederer 和
protected override void OnElementPropertyChanged(object sender,
System.ComponentModel.PropertyChangedEventArgs e)
{
// Change the text on custompropertychange
base.OnElementPropertyChanged(sender, e);
Control.SetText("CustomText", TextView.BufferType.Spannable);
}
关于android - Xamarin Forms 编辑器文本未在 android 上正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43265105/