Bug 29214 - Setting button as visible with IsVisible causes text layout options to be ignored
Summary: Setting button as visible with IsVisible causes text layout options to be ign...
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 1.4.2
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-04-17 17:18 UTC by Cody Beyer (MSFT)
Modified: 2015-07-16 08:41 UTC (History)
5 users (show)

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


Attachments
Test case, cleaned (176.39 KB, application/zip)
2015-04-17 18:03 UTC, Brendan Zagaeski (Xamarin Team, assistant)
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:
VERIFIED FIXED

Description Cody Beyer (MSFT) 2015-04-17 17:18:29 UTC
### Description

While in Android and when setting a button as visible via IsVisible, the text layout options of said button are not respected

### Test Case

https://www.dropbox.com/s/uq075oulk79ratv/BugChecks.zip?dl=0

### Steps to Reproduce

1. Open linked test case
2. Deploy to Android simulator
3. Click on "Test"

### Expected Results

The button that is displayed should have centered text 

### Actual Results

The button that is displayed has left justified text

### Version

=== Xamarin Studio ===

Version 5.9 (build 427)
Installation UUID: d34df35e-adee-41f6-9712-e66a1d4e7768
Runtime:
	Mono 4.0.0 ((detached/d136b79)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000143

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.10.0.258 (Business Edition)
Hash: c2c0012
Branch: master
Build date: 2015-04-14 17:26:21-0400

=== Xamarin.Mac ===

Version: 2.0.0.258 (Business Edition)

=== Xamarin.Android ===

Version: 5.1.0.113 (Business Edition)
Android SDK: /Users/beyerc/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 509000427
Git revision: 04666fd43a57b4782529cad9723ce1f54926fe6c
Build date: 2015-04-14 18:06:43-04
Xamarin addins: 791954691dfbc403676a103e52a0bb9754b9af29

=== Operating System ===

Mac OS X 10.10.3
Darwin BeyerStudiosMBP.router 14.3.0 Darwin Kernel Version 14.3.0
    Mon Mar 23 11:59:05 PDT 2015
    root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2015-04-17 18:03:32 UTC
Created attachment 10807 [details]
Test case, cleaned

Just for convenience, I've cleaned out the `packages` folder, and attached the test case directly on the bug report.


## Temporary workaround

In case it might be helpful as temporary workaround, you can use the "old trick" of moving initialization of various things into the `LayoutChildren()` override so that they run later:


> bool loaded = false;
> 
> protected override void LayoutChildren(double x, double y, double width, double height)
> {
>     base.LayoutChildren(x, y, width, height);
> 
>     if (!loaded) {
>         this.button2.IsVisible = false;
>         loaded = true;
>     }
> } 

(Remove the > greater-than symbols from the beginning of each line.)


Adding these lines to the `TestPage` class and removing the original `this.button2.IsVisible = false` line seemed to work around the problem successfully in my quick tests.



## Version information

Tested on stable:
Xamarin.Forms 1.4.1.6349

And pre-release:
Xamarin.Forms 1.4.2.6353-pre2


### Other version info

Tested on emulator: Xamarin Android Player 0.3.7 (1), Nexus 4 (KitKat) image


Xamarin.Android 5.1.0.113 (Business Edition)

Mono 4.0.0 ((detached/d136b79)

Xamarin Studio 5.9 (build 426)
Git revision: 5b9ada95416f6309d7ec20ecbc62678b70ea19e9
Build date: 2015-04-14 06:28:02-04
Xamarin addins: ad73c94cbb6e54814cef6854ebccbfa48fe331f6
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2015-04-17 18:06:01 UTC
Marking as confirmed since I was able to reproduce the issue using the steps listed in comment 0.
Comment 3 Jason Smith [MSFT] 2015-06-18 14:44:08 UTC
Should be fixed in 1.4.4-pre1
Comment 4 Parmendra Kumar 2015-07-16 08:41:56 UTC
I have checked this issue with X.F 1.4.4-pre1 and its working fine at my end.


Hence closing this issue.