How to consistently set EditText Selected Underline Color Programmatically

前端 未结 5 2023
情深已故
情深已故 2021-02-20 09:05

I\'m trying to build a renderer for Xamarin Forms. The renderer needs to set the EditText underline color to \"Active Color\" when selected and \"Hint Color\" when

5条回答
  •  执笔经年
    2021-02-20 09:46

    Modify your code in XfxEntryRendererDroid ControlOnFocusChange method like this :

    private void ControlOnFocusChange(object sender, FocusChangeEventArgs args)
    {
        _hasFocus = args.HasFocus;
        if (_hasFocus)
        {
            ...   
    
            EditText.PostDelayed(() =>
                {
                    //Add the following code
                    SetUnderlineColor(GetActivePlaceholderColor());
                    EditText.RequestFocus();
                    manager.ShowSoftInput(EditText, 0);
                },
                0);//Change it to 0
        }
        ...
    }
    

    Effect.

提交回复
热议问题