Forum Xamarin.Android

How to set a different background color for function keys in xml on custom numeric keyboard?

Sudheer_469Sudheer_469 Member ✭✭
edited February 17 in Xamarin.Android

I am developing a custom numeric keyboard for Android. I tried to set different background color for function keys, number keys back ground color set as expected but i am trying different properties for function keys but not worked please give me a suggestion i need to implement below keypad

Answers

  • YelinzhYelinzh Member, Xamarin Team Xamurai

    Try to override the KeyboardView class to re-write the OnDraw method to set background for the keys.

    public class CustomKeyboardView : KeyboardView
    {
        public override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);
    
            var keys = this.Keyboard.Keys;
            foreach (var key in keys)
            {
                //draw the background for the key
            }
        }
        ...
    }
    

    Here is the similar case link, you could refer to:
    https://stackoverflow.com/questions/17714172/how-to-change-key-background-of-any-key-in-android-soft-keyboard/22454382#22454382

  • Sudheer_469Sudheer_469 Member ✭✭

    Thanks for reply @Yelinzh how to call onDraw method in Custom render

  • YelinzhYelinzh Member, Xamarin Team Xamurai

    how to call onDraw method in Custom render

    Do you test on a Xamarin.Forms project? Try to create a custom keyboard view on the Android platform. Then create a custom renderer for the input control such as Entry and set the keyboard for the control.

    You could google with the keyword as How to create a custom keyboard with Xamarin Forms (Android) to check the related document.

Sign In or Register to comment.