InputTransparent = true在Xamarin Forms Android中不起作用

前端之家收集整理的这篇文章主要介绍了InputTransparent = true在Xamarin Forms Android中不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
this链接.

false if the element should receive input; true if element should not receive input and should,instead,pass inputs to the element below. Default is false.

我想要的是,不允许Entry字段接收来自用户的输入.

InputTransparent = true在iOS中运行良好但在Android中不起作用,它仍然允许用户提供输入.

我尝试过IsEnabled = false,但这会改变我的Entry字段的外观,我不希望这样.

这是某种错误吗?

解决方法

InputTransparent不适用于Android.我为StackLayout创建了简单的渲染:

在PCL项目中:

@H_404_20@public class StackLayoutAdd :StackLayout { }

在Android项目中:

@H_404_20@[assembly: ExportRenderer(typeof(StackLayoutAdd),typeof(StackLayoutAddCustom))] ..... public class StackLayoutAddCustom : VisualElementRenderer<StackLayout> { public override bool DispatchTouchEvent(MotionEvent e) { base.DispatchTouchEvent(e); return !Element.InputTransparent; } }

我在我的xaml中使用它:

@H_404_20@<StackLayoutAddCustom InputTransparent={Binding IsReadOnly}> <Editor /> .... </StackLayoutAddCustom>

这是儿童控制的工作.

猜你在找的Android相关文章