Bug 58772 - Text in Label does not stay centered after navigating away and then back to a page
Summary: Text in Label does not stay centered after navigating away and then back to a...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-08-15 15:11 UTC by YLNK
Modified: 2017-09-16 23:58 UTC (History)
2 users (show)

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


Attachments
Text appearance before navigating away (35.19 KB, image/png)
2017-08-15 15:11 UTC, YLNK
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 ANSWERED

Description YLNK 2017-08-15 15:11:00 UTC
Created attachment 24195 [details]
Text appearance before navigating away

Xamarin Forms version: 2.3.4.247

Visual Studio 2017 Professional

Xamarin version: 4.5.0.486

Xamarin.Android.SDK: 7.3.1.2

Android device version: 7.0


I am only seeing this happen on Android. I do not see this behaviour on iOS at all.


The label is defined as:

<Label x:Name="connectedDevice" FontAttributes="Bold" FontSize="Large" HorizontalTextAlignment="Center" Grid.Row="0"></Label>


I currently do not have an override on `OnAppearing`. This happens after a single navigation away and then back to the page.


When the app loads the first page displayed is the page in the screenshot. Bluetooth devices are scanned, the user selects a device, and the label above is changed with 'connectedDevice.Text = " Connected to: " + bd.DisplayName + "\n Battery: " + App.BatteryLevel + "%";`. Any amount of altering the text in the Label while still on the page will not cause the text to become left-justified. It is only after navigating to say the 'Train' page then back to 'Settings'

It looks as though the text stays centered relative to itself, in that the 2nd line of the text is centered relative to the first line, however it becomes left-justified.
Comment 1 Paul DiPietro [MSFT] 2017-08-15 15:20:54 UTC
Have you tested this against the latest prerelease or nightly build to see if the issue has been resolved already? Does it only occur when you're using a TabbedPage, or on certain devices/Android versions? Can you upload a reproduction project as well that we can refer to?
Comment 2 YLNK 2017-08-15 15:34:33 UTC
It appears setting 'HorizontalOptions="CenterAndExpand"' on the Label has fixed the issue, however it may be worth noting that this is not necessary on iOS.

I will update again if I see the issue come back.
Comment 3 Paul DiPietro [MSFT] 2017-09-16 23:58:53 UTC
As it has been over 30 days without an update, we will assume this is no longer an issue for you. If there is a clear and reproducible bug (with a provided reproduction project), please submit one and reopen as necessary.