Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.
Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.
Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.
Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.
Created attachment 7389 [details] button text moves... See this example code. http://forums.xamarin.com/discussion/20501/is-layout-badly-broken-or-am-i-just-not-getting-it If you click on "Add Control", the "add control" text jumps to the left of the button... using System; using Xamarin.Forms; namespace TestEditor { public class App { static ScrollView _scrollView; static StackLayout _buttonsStack; static Grid _buttonsGrid; public static Page GetMainPage() { _scrollView = new ScrollView { Orientation = ScrollOrientation.Horizontal, Content = new StackLayout { Orientation = StackOrientation.Horizontal }, HeightRequest = 100 }; _buttonsGrid = new Grid { RowSpacing = 10, }; _buttonsGrid.Children.Add (_scrollView,0,0); _buttonsGrid.Children.Add (new Button { Text = "Add Control", Command = new Command (OnAddControl), WidthRequest=400 }, 0, 1); _buttonsGrid.Children.Add (new Button { Text = "Insert Control", Command = new Command (OnInsertControl) }, 0, 2); _buttonsGrid.Children.Add (new Button { Text = "Remove Control", Command = new Command (OnRemoveControl) }, 0, 3); _buttonsStack = new StackLayout{ Children = {_buttonsGrid} }; return new ContentPage { Content = new StackLayout { Orientation = StackOrientation.Vertical, Children = { _buttonsStack } } }; } private static StackLayout ScrollStackLayout { get { return (StackLayout)_scrollView.Content; } } private static void OnAddControl() { ScrollStackLayout.Children.Add(new Button { Text = "hello" }); ForceRelayout(); } private static void OnInsertControl() { ScrollStackLayout.Children.Insert(0, new Button { Text = "hello" }); ForceRelayout(); } private static void OnRemoveControl() { if (ScrollStackLayout.Children.Count > 0) { ScrollStackLayout.Children.RemoveAt(0); ForceRelayout(); } } private static void ForceRelayout() { ScrollStackLayout.ForceLayout(); _scrollView.ForceLayout(); } } }
the code above is the workaround code... the original code which shows the bug is here. sorry for that. public class App { //broken alignment static ScrollView _scrollView; static StackLayout _buttonsStack; public static Page GetMainPage() { _scrollView = new ScrollView { Orientation = ScrollOrientation.Horizontal, Content = new StackLayout { Orientation = StackOrientation.Horizontal }, HeightRequest = 100 }; _buttonsStack = new StackLayout { Children = { new Button { Text = "Add Control", Command = new Command(OnAddControl) }, new Button { Text = "Insert Control", Command = new Command(OnInsertControl) }, new Button { Text = "Remove Control", Command = new Command(OnRemoveControl) } } }; return new ContentPage { Content = new StackLayout { Orientation = StackOrientation.Vertical, Children = { _scrollView, _buttonsStack } } }; } private static StackLayout ScrollStackLayout { get { return (StackLayout)_scrollView.Content; } } private static void OnAddControl() { ScrollStackLayout.Children.Add(new Button { Text = "Hello" }); ForceRelayout(); } private static void OnInsertControl() { ScrollStackLayout.Children.Insert(0, new Button { Text = "Hello" }); ForceRelayout(); } private static void OnRemoveControl() { if (ScrollStackLayout.Children.Count > 0) { ScrollStackLayout.Children.RemoveAt(0); ForceRelayout(); } } private static void ForceRelayout() { ScrollStackLayout.ForceLayout(); _scrollView.ForceLayout(); } }
I have checked this issue and able to reproduce it. Steps to reproduce this issue. 1.Create a Xamarin PCL Forms application. 2.Add above code in App.cs . 3.Run the application. I observed that when i clicked on Add Control text of control jumps to left and also observed that randomly click on Add control and Insert control .Added control text sometimes jumps to top ,sometimes right. Screencast: http://screencast.com/t/1b6TI4vR6 Environment Info: XVS 3.3.47.0 Xamarin Form version: 1.2.2.6243
A smaller code example which reproduces this bug can be found at http://stackoverflow.com/questions/26056519/xamarin-forms-wrong-button-text-alignment-after-click-android. The Workaround is a very small addition to the ButtonRenderer: public override void ChildDrawableStateChanged(Android.Views.View child) { base.ChildDrawableStateChanged(child); Control.Text = Control.Text; }