New to Telerik UI for Xamarin? Download free 30-day trial

DataForm change editor text font size on Android

Environment

Product Version 2021.2.512.1
Product DataForm for Xamarin Cross-Platform

Description

This articleshows how to chage the DataForm editors font size on Android

Solution

Custom Renderer is needed for this scenario. Create a class CustomDataFormRenderer which inherits from DataFormRenderer. Then override the UpdateEditor method and use the SetTextSize method to change the Font Size of the EditorView text:

using Android.Content;
using Android.Runtime;
using AndroidX.AppCompat.Widget;
using App1.Droid;
using Com.Telerik.Widget.Dataform.Visualization.Core;
using Com.Telerik.Widget.Dataform.Visualization.Editors;
using Telerik.XamarinForms.InputRenderer.Android;
using Xamarin.Forms;

[assembly: ExportRenderer(typeof(Telerik.XamarinForms.Input.RadDataForm), typeof(CustomDataFormRenderer))]

namespace App1.Droid
{
    public class CustomDataFormRenderer : DataFormRenderer
    {
        public CustomDataFormRenderer(Context context) : base(context)
        {
        }

        protected override void UpdateEditor(EntityPropertyEditor editor, Telerik.XamarinForms.Input.DataForm.IEntityProperty property)
        {
            base.UpdateEditor(editor, property);

            if (editor is DataFormTextEditor || editor is DataFormDecimalEditor || editor is DataFormIntegerEditor)
            {
                var editText = editor.EditorView.JavaCast<AppCompatEditText>();
                editText.SetTextSize(Android.Util.ComplexUnitType.Px, 80);
            }
        }
    }
}
In this article