using System;
using Android.Content.Res;
using Android.Graphics;
using Android.Graphics.Drawables;
using Android.Views;
using Android.Views.InputMethods;
using Android.Widget;
using AndroidX.AppCompat.Widget;
using AndroidX.Core.Content;
using AndroidX.Core.Content.Resources;
using AndroidX.Core.Graphics;
using AndroidX.Core.View;
using Maui.FreakyControls.Platforms.Android.NativeControls;
using Microsoft.Maui.Handlers;
using Color = Microsoft.Maui.Graphics.Color;
namespace Maui.FreakyControls
{
public partial class FreakyEditorHandler
{
protected override AppCompatEditText CreatePlatformView()
{
var _nativeView = new AppCompatEditText(Context)
{
ImeOptions = ImeAction.Done,
Gravity = GravityFlags.Top,
TextAlignment = Android.Views.TextAlignment.ViewStart,
};
_nativeView.SetSingleLine(false);
var colorStateList = ColorStateList.ValueOf(Android.Graphics.Color.Transparent);
ViewCompat.SetBackgroundTintList(_nativeView, colorStateList);
_nativeView.SetHorizontallyScrolling(false);
return _nativeView;
}
internal void HandleAllowCopyPaste(FreakyEditor editor)
{
if (editor.AllowCopyPaste)
{
PlatformView.CustomInsertionActionModeCallback = null;
PlatformView.CustomSelectionActionModeCallback = null;
}
else
{
PlatformView.CustomInsertionActionModeCallback = new CustomInsertionActionModeCallback();
PlatformView.CustomSelectionActionModeCallback = new CustomSelectionActionModeCallback();
}
}
}
}
1条答案
按热度按时间cwdobuhd1#
如果你有一个处理程序,它将帮助你通过使用你的Native Partial类中的PlatformView属性来做到这一点。现在你可以做的就是简单地检查这个博客,看看哪个控件使用了什么处理程序https://learn.microsoft.com/en-us/dotnet/maui/user-interface/handlers/,然后基于此创建你的处理程序。
一旦准备好了,你就可以在你的Native Partial Class中使用PlatformView属性。
示例如下:
检查我的图书馆;它有一堆原生用法的例子:https://github.com/FreakyAli/Maui.FreakyControls