最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

custom controls - Customizing a Border Around Pickers for Android on Maui using Handlers and Mappers - Stack Overflow

programmeradmin0浏览0评论

I am trying to add a Custom Border around the Picker for Android but my code provided does not seem to be doing anything.

            Microsoft.Maui.Handlers.PickerHandler.Mapper.AppendToMapping("PickerBorder", (handler, view) =>
            {
#if ANDROID
                var border = new Android.Graphics.Drawables.GradientDrawable();
                border.SetShape(Android.Graphics.Drawables.ShapeType.Rectangle);
                border.SetStroke(4, Android.Graphics.Color.Red);
                border.SetCornerRadius(12);
                handler.PlatformView.SetBackground(border);
#elif IOS || MACCATALYST

#elif WINDOWS

#endif
            });

My handler is registered, how I know this is when I only have:

 handler.PlatformView.BackgroundTintList = ColorStateList.ValueOf(Android.Graphics.Color.Transparent);

-added to the Mapper, it does remove the underline in the picker. Would anyone happen to know what I am missing?

I am trying to add a Custom Border around the Picker for Android but my code provided does not seem to be doing anything.

            Microsoft.Maui.Handlers.PickerHandler.Mapper.AppendToMapping("PickerBorder", (handler, view) =>
            {
#if ANDROID
                var border = new Android.Graphics.Drawables.GradientDrawable();
                border.SetShape(Android.Graphics.Drawables.ShapeType.Rectangle);
                border.SetStroke(4, Android.Graphics.Color.Red);
                border.SetCornerRadius(12);
                handler.PlatformView.SetBackground(border);
#elif IOS || MACCATALYST

#elif WINDOWS

#endif
            });

My handler is registered, how I know this is when I only have:

 handler.PlatformView.BackgroundTintList = ColorStateList.ValueOf(Android.Graphics.Color.Transparent);

-added to the Mapper, it does remove the underline in the picker. Would anyone happen to know what I am missing?

Share Improve this question asked Mar 11 at 14:28 ShannonShannon 132 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0
        PickerHandler.Mapper.AppendToMapping("Background", (handler, view) =>
        {
            var border = new Android.Graphics.Drawables.GradientDrawable();
            border.SetShape(Android.Graphics.Drawables.ShapeType.Rectangle);
            border.SetStroke(4, Android.Graphics.Color.Red);
            border.SetCornerRadius(12);

            handler.PlatformView.Background = border;
        });

Is this the result are you looking for?

Tested on 9 (Microsoft.Maui.Controls 9.0.14)

For 8, maybe this issue could be helpful

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论