[Android] fixes TabStop on Stepper Control (#5000) fixes #4956
authorPavel Yakovlev <v-payako@microsoft.com>
Tue, 12 Feb 2019 13:39:03 +0000 (16:39 +0300)
committerRui Marinho <me@ruimarinho.net>
Tue, 12 Feb 2019 13:39:03 +0000 (13:39 +0000)
Xamarin.Forms.Platform.Android/Renderers/StepperRenderer.cs

index 1604d0d..353b2c8 100644 (file)
@@ -27,7 +27,12 @@ namespace Xamarin.Forms.Platform.Android
 
                protected override LinearLayout CreateNativeControl()
                {
-                       return new LinearLayout(Context) { Orientation = Orientation.Horizontal };
+                       return new LinearLayout(Context)
+                       {
+                               Orientation = Orientation.Horizontal,
+                               Focusable = true,
+                               DescendantFocusability = DescendantFocusability.AfterDescendants
+                       };
                }
 
                protected override void OnElementChanged(ElementChangedEventArgs<Stepper> e)
@@ -36,16 +41,18 @@ namespace Xamarin.Forms.Platform.Android
 
                        if (e.OldElement == null)
                        {
-                               _downButton = new AButton(Context) { Text = "-", Gravity = GravityFlags.Center, Tag = this };
+                               _downButton = new AButton(Context) { Text = "-", Gravity = GravityFlags.Center, Tag = this, Focusable = true };
                                _downButton.SetHeight((int)Context.ToPixels(10.0));
 
                                _downButton.SetOnClickListener(StepperListener.Instance);
 
-                               _upButton = new AButton(Context) { Text = "+", Tag = this };
+                               _upButton = new AButton(Context) { Text = "+", Tag = this, Focusable = true };
 
                                _upButton.SetOnClickListener(StepperListener.Instance);
                                _upButton.SetHeight((int)Context.ToPixels(10.0));
 
+                               _downButton.NextFocusForwardId = _upButton.Id = Platform.GenerateViewId();
+
                                var layout = CreateNativeControl();
 
                                layout.AddView(_downButton);