【问题标题】:Xamarin Forms editor text not showing correctly on androidXamarin Forms 编辑器文本未在 android 上正确显示
【发布时间】:2017-04-06 20:24:04
【问题描述】:

我在应用程序中有此页面,我需要将一些编辑器组件放置在特定位置和特定位置。但是,当我设置一个小的 HeightRequest 时,编辑器无法在 android 上正确显示文本。

我尝试调整 FontSize 和 Margin 以正确显示,但它们似乎都没有任何效果。

以下是来自 iOS: 和 Android: 的屏幕。

我应该怎么做才能在 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));
            });

【问题讨论】:

  • 您是否正在处理页面的第三部分?能否请您发布您的代码?
  • 编辑了一些代码和说明

标签: android xamarin editor


【解决方案1】:

你必须写 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);     
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-16
    • 2017-12-25
    • 1970-01-01
    • 2019-02-10
    • 1970-01-01
    • 2022-01-08
    • 1970-01-01
    • 2020-07-18
    相关资源
    最近更新 更多