Проблема с фокусировкой ввода внутри горизонтальAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Проблема с фокусировкой ввода внутри горизонталь

Сообщение Anonymous »

Я испытываю проблему с записью внутри нативного Android horizontalscrollview, который я интегрировал с использованием картирования обработчиков в приложении Maui. экран), запись неожиданно получает фокус.

Код: Выделить всё

public partial class MainPage : ContentPage
{
Entry mauiEntry;
public MainPage()
{
InitializeComponent();

// Initialize the Entry
mauiEntry = new Entry
{
Placeholder = "Type here",
BackgroundColor = Colors.LightGray,
TextColor = Colors.Black,
HeightRequest = 40,
WidthRequest = 200
};

// Create the innermost view that will contain the Entry
var innerView = new ContentView
{
Content = mauiEntry,
BackgroundColor = Colors.Beige,
Padding = new Thickness(10)
};

// Create the middle view that contains the inner view
var middleView = new ContentView
{
Content = innerView,
BackgroundColor = Colors.Yellow,
WidthRequest = 300,
HeightRequest = 500,
Padding = new Thickness(20)
};

// Create the top-level grid that contains the middle view
var container = new Grid
{
WidthRequest = 350,
HeightRequest = 550,
BackgroundColor = Colors.Violet
};

// Add the middle view to the grid
container.Children.Add(middleView);

var horizontalScrollWrapper = new InteractiveScrollViewExt(container)
{
BackgroundColor = Colors.LightPink
};

myGrid.Children.Add(horizontalScrollWrapper);
}

private void Unfocu_Clicked(object sender, EventArgs e)
{
mauiEntry.Unfocus();
}
}

public class InteractiveScrollViewExt : View
{
public View Content { get; }
public InteractiveScrollViewExt(View child) => Content = child;
}

public class InteractiveScrollViewExtHandler : ViewHandler
{
public InteractiveScrollViewExtHandler() : base(ViewHandler.ViewMapper)
{
}

protected override HorizontalScrollViewer CreatePlatformView()
{
var context = MauiApplication.Current.ApplicationContext!;
var scrollView = new HorizontalScrollViewer(context);
if (VirtualView.Content is not null)
{
var viewHandler = VirtualView.Content.ToHandler(MauiContext!);
var platformView = viewHandler.PlatformView as Android.Views.View;
scrollView.AddView(platformView);
}
return scrollView;
}
}

public class HorizontalScrollViewer : HorizontalScrollView
{
public HorizontalScrollViewer(Context? context) : base(context)
{
this.ClipToOutline = true;
}
}
`
Почему вход приобретает фокусировку при прохождении в любом месте внутри Horizontalscrollview ?
ожидаемое поведение:

inpit должна получить фокус только при напряжении. Свигарование или постукивание в других местах в горизонтальскриллхвел не должно влиять на его состояние фокуса.

Подробнее здесь: https://stackoverflow.com/questions/797 ... on-android
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»