Bug 21138 - [Android only] Label text alignment changes after button is pressed
Summary: [Android only] Label text alignment changes after button is pressed
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.1.1
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
: 21608 ()
Depends on:
Blocks:
 
Reported: 2014-07-06 00:41 UTC by Daniel Drysdale
Modified: 2015-02-23 13:40 UTC (History)
10 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Button before press (12.00 KB, image/png)
2014-07-06 00:41 UTC, Daniel Drysdale
Details
Button after press (11.33 KB, image/png)
2014-07-06 00:41 UTC, Daniel Drysdale
Details
Page source (1.59 KB, application/octet-stream)
2014-07-06 00:42 UTC, Daniel Drysdale
Details
Test Case (4.68 MB, application/zip)
2014-07-22 19:34 UTC, John Miller [MSFT]
Details


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.

Related Links:
Status:
RESOLVED FIXED

Description Daniel Drysdale 2014-07-06 00:41:23 UTC
Created attachment 7278 [details]
Button before press

On Android, a button in a stack layout with HorizontalOptions = LayoutOptions.Center initially has the button text centered, once the button is pressed the text alignment changes to left justified ( sometimes the button may need to be pressed twice to trigger the problem.
Comment 1 Daniel Drysdale 2014-07-06 00:41:55 UTC
Created attachment 7279 [details]
Button after press
Comment 2 Daniel Drysdale 2014-07-06 00:42:40 UTC
Created attachment 7280 [details]
Page source
Comment 3 John Miller [MSFT] 2014-07-22 19:33:18 UTC
I have seen something similar in 1.2.2.6240-pre2. I am not sure if it's the same bug.

### Overview

    After a modal page presentation, the button text alignment can change from center to left aligned.
    Here is a screencast of the issue: http://screencast.com/t/IXyImCGxzKB

### Steps to Reproduce

   1. Download my attached sample project.
   2. Press the "Click Me" button.
   3. The TestPage is presented as a modal page.
   4. Press the hardware back button.
   5. Repeat steps 3-4 until the text alignment changes (usually 2 attempts).

### Expected Results

    Alignment stays the same. 

### Additional Info

    Removed the private status of this bug.
Comment 4 John Miller [MSFT] 2014-07-22 19:34:06 UTC
Created attachment 7462 [details]
Test Case
Comment 5 Eric Maupin 2014-07-28 11:52:45 UTC
*** Bug 21608 has been marked as a duplicate of this bug. ***
Comment 6 Eric Maupin 2014-07-28 11:53:31 UTC
Fixed for next update.
Comment 7 daniel.luberda 2014-07-29 10:16:10 UTC
Test Case from bug 21608  (duplicate) is still valid i 1.2.2 pre3 when tested on DEVICE (important)
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-26 01:44:24 UTC
The release notes for 1.2.2 do mention this bug [1], but unfortunately, it looks like the issue is not resolved for the test case from comment 4; the test case from bug 21608, comment 0; or the test case from bug 23393, comment 0.

[1] "[Android] Button text no longer will randomly re-align to the left side of the screen"
> http://forums.xamarin.com/discussion/21374/xamarin-forms-1-2-2-released


## Additional test case

The test case from bug 23393, comment 0 reliably shows the problematic behavior on physical devices and emulators after a single button-tap. The re-alignment happens when the text of either of the Labels (above and below the Button in the StackLayout) is updated by the data binding. Removing the bindings for the Text properties on both Labels stops the problem.

The test case from bug 21608, comment 0 does something similar.

On Windows Phone and iOS, the button text stays centered during all button presses. 



## Version information

Xamarin.Forms 1.2.3.6255-pre3
Xamarin.Android.Support 20.0.0.4
WPtoolkit 4.2013.08.16

Xamarin   3.7.126.0 (d5382b8b3a2baf01a2413b145b96b5563d75d4c8)
Xamarin.Android   4.18.0.24 (3ebb5e477e2d3a62f6ba7a0dbc774bdfba2da1c9)
Xamarin.iOS   8.2.57.0 (06491f39c4d42b5fe5b685ef91a843177f5e7247)

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-30 13:43:55 UTC
Additional discussion in the comments on the 1.2.3 prerelease 4 release thread:
https://forums.xamarin.com/discussion/24956/xamarin-forms-1-2-3-prerelease-4-out/p1

There's a detailed assessment of the problem in the case of using native Android widgets in a non-Xamarin.Forms app from a user in one of the posts there:
https://forums.xamarin.com/discussion/comment/78928/#Comment_78928
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2014-09-30 13:49:31 UTC
## Possible workaround

Another of the posts on the 1.2.3 prerelease 4 forum thread links to a StackOverflow question that includes a workaround:
http://stackoverflow.com/questions/26056519/xamarin-forms-wrong-button-text-alignment-after-click-android
Comment 11 Ryan Hatfield 2014-10-16 21:02:12 UTC
Here's a screencast and an additional reproduction to test against
http://screencast-o-matic.com/watch/c26bcNejBU

https://www.dropbox.com/s/x12ih6qtv6a3sba/ButtonTextMoves.zip?dl=0
Comment 12 Jason Smith [MSFT] 2015-01-31 01:10:12 UTC
Should be fixed
Comment 13 Chase Florell 2015-02-19 17:58:19 UTC
Still not fixed in 1.3.4, previous renderer workaround doesn't seem to resolve it anymore either.
Comment 14 Brendan Zagaeski (Xamarin Team, assistant) 2015-02-19 19:32:53 UTC
I quickly checked the test cases from comment 4; bug 21608, comment 0; and bug 23393, comment 0. I built and ran the projects in the Debug configuration, using fast deployment.


All 3 test cases reproduced the problem when using Xamarin.Forms 1.2.3.6257, but *worked correctly* when updated to Xamarin.Forms 1.3.4.6332.


Note that there is one similar known open issue that affects specific devices (including the Samsung Galaxy S2): bug 26696.


If anyone can reproduce the original problem using one of the exact test cases I tried (comment 4; bug 21608, comment 0; or bug 23393, comment 0), and the symptoms you're seeing do not match bug 26696, then be sure to let us know:

- Which test case demonstrates the problem.
- What devices were used for testing.


If the problem can only be reproduced using a _different_ test case, please file a new bug report that includes the new test case (ideally a complete zipped up project that is as simple as possible). See also https://bugzilla.xamarin.com/page.cgi?id=bug-writing.html for additional information to include on the bug report.


Thanks!


## Version info
Xamarin.Forms 1.3.4.6332

### Devices tested
- Xamarin Android Player, Nexus 4, Android 4.4.2
- LG Optimus L9 (LGMS769), Android 4.1.2
Comment 15 Brendan Zagaeski (Xamarin Team, assistant) 2015-02-23 13:40:02 UTC
In addition to Samsung Galaxy S2 devices (bug 26696), it appears that Android 5.0 devices also still demonstrate this problem: bug 27314.

The fixes for each of those problems will be tracked on those separate bug reports.