Bug 27731 - [Android] Action Bar can not be controlled reliably on MasterDetailPage
Summary: [Android] Action Bar can not be controlled reliably on MasterDetailPage
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android (show other bugs)
Version: 1.4.2
Hardware: PC Windows
: Normal enhancement
Target Milestone: 2.4.0
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2015-03-06 10:19 UTC by Tibor Ebner
Modified: 2017-09-18 14:39 UTC (History)
13 users (show)

See Also:
Tags: ac android visual navigationpage masterdetailpage barbackgroundcolor
Is this bug a regression?: ---
Last known good build:


Attachments
Demo project that illustrates the issue (4.39 MB, application/zip)
2015-03-06 10:19 UTC, Tibor Ebner
Details
New repro project (175.06 KB, application/zip)
2015-04-22 19:01 UTC, Jimmy [MSFT]
Details
Logs from comment 2 (92.11 KB, application/zip)
2015-04-22 19:50 UTC, Jon Goldberger [MSFT]
Details
Color change bug with MasterDetailPage (57.25 KB, application/octet-stream)
2016-01-23 07:04 UTC, adrianknight89
Details

Description Tibor Ebner 2015-03-06 10:19:47 UTC
Created attachment 10187 [details]
Demo project that illustrates the issue

The issue is that the Action Bar coloring and whether a NavigationPage has a visible Action Bar or not cannot be set reliably when NavigationPages are used in a MasterDetailPage. This bug is present since at least v1.2.x and easily reproducible (and unfortunately very conspicuous) both on emulator and physical device, yet despite new releases coming in rapid succession, there were no improvements in this regard whatsoever. In practical situations we cannot set the Action Bar's background color without it resetting to default on further pushed/popped pages. Additionally, the Action Bar apparently cannot be switched off for pages that are root pages in a NavigationPage (in a MasterDetailPage).

The attached demo project clearly illustrates the problem where the root page of a navigation hierarchy cannot be switched to full screen. The specific design intention here was to have the '1st Page' full screen and the '2nd Page' with an Action Bar with specified background color. The goal could be achieved by a hack which is demonstrated in the 'Leaf Page' side menu item. The hack was to insert a dummy (empty) page as root in front of the '1st Page'. The 'Page Hierarchy' side menu item contains the natural solution which doesn't work: '1st Page' is not full screen, and successor pages loose their preset Action Bar background color (blue in this case).

Platform info for reproduction:
-------------------------------
Xamarin Studio
Version 5.7.2 (build 7)
Installation UUID: c6eee852-199d-4124-9043-43a061cc9e2d
Runtime:
	Microsoft .NET 4.0.30319.34209
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

Xamarin.Android
Version: 4.20.0 (Indie Edition)
Android SDK: C:\Users\adinatha\Android\sdk
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: C:\Program Files\Java\jdk1.6.0_45
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Build Information
Release ID: 507020007
Git revision: dcf3f486177d3e625349b51a8f3be807e3fa7712
Build date: 2015-02-24 05:29:53-05
Xamarin addins: ea7c65bb7876e4a876ab365208e94acdf8f330ef

Operating System
Windows 6.1.7601.65536 (64-bit)

Emulator
Genymotion 2.3.1 with image Google Galaxy Nexus 4.1.1 (API 16)

Physical devices:
Samsung Galaxy S Advance (4.1.2)
Motorola Moto G (4.4.2)
Comment 1 Jimmy [MSFT] 2015-04-22 19:01:29 UTC
Created attachment 10874 [details]
New repro project

I've attached a new repro project that demonstrates the issue where the navigation bar does not hide on the first(root) detail page in the MDPage.

*** Steps to Reproduce ***
1. Run the repro project
2. Note that the first page has the navigation bar
3. Click on the button
4. The page that is pushed (and subsequent pages) will hide the navigation bar


*** Actual Results ***
Even though Page2.cs has NavigationPage.SetHasNavigationBar(this, false) the navigation bar is still present when it is the root detail page.


*** Expected Results ***
The navigation bar is hidden whenever a page has NavigationPage.SetHasNavigationBar(this, false). 

Note: The navigation bar hides as expected in iOS even on the root detail page.


*** Environment Info ***
=== Xamarin Studio ===

Version 5.8.3 (build 1)
Installation UUID: 94ce5106-6a72-4691-b34e-cd5857b1db66
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

=== Xamarin.Android ===

Version: 4.20.2.1 (Business Edition)
Android SDK: /Users/jimmygarrido/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.0   (API level 21)
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

=== Apple Developer Tools ===

Xcode 6.3 (7569)
Build 6D570

=== Xamarin.iOS ===

Version: 8.9.1.3 (Business Edition)
Hash: f7736a4
Branch: 
Build date: 2015-04-09 04:22:08-0400

=== Xamarin.Mac ===

Version: 1.12.0.14 (Business Edition)

=== Build Information ===

Release ID: 508030001
Git revision: 6e8e725e0d689351901c2c70453bfa4ea25e293b
Build date: 2015-04-06 20:31:47-04
Xamarin addins: 051cd5f8c1b5dbfc87eaef80a74aec03f34c60a8

=== Operating System ===

Mac OS X 10.10.3
Darwin Jimmys-MacBook-Pro.local 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 2 Jon Goldberger [MSFT] 2015-04-22 19:50:13 UTC
I was able to reproduce this issue following the steps in Comment 1 and using the "New repro project".

Screencast: http://screencast.com/t/FAFngyHE

## MyEnvironment:

=== Xamarin Studio ===

Version 5.8.3 (build 1)
Installation UUID: 2dc9022f-f9a8-424f-8284-bf224cbbfde0
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

=== Apple Developer Tools ===

Xcode 6.3.1 (7703)
Build 6D1002

=== Xamarin.iOS ===

Version: 8.9.1.3 (Business Edition)
Hash: f7736a4
Branch: 
Build date: 2015-04-09 04:22:08-0400

=== Xamarin.Android ===

Version: 4.20.2.1 (Business Edition)
Android SDK: /Users/apple/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin Android Player ===

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

=== Xamarin.Mac ===

Version: 1.12.0.14 (Business Edition)

=== Build Information ===

Release ID: 508030001
Git revision: 6e8e725e0d689351901c2c70453bfa4ea25e293b
Build date: 2015-04-06 20:31:47-04
Xamarin addins: 051cd5f8c1b5dbfc87eaef80a74aec03f34c60a8

=== Operating System ===

Mac OS X 10.10.3
Darwin Jons-iMac.local 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 3 Jon Goldberger [MSFT] 2015-04-22 19:50:43 UTC
Created attachment 10876 [details]
Logs from comment 2
Comment 4 Tibor Ebner 2015-04-23 03:23:44 UTC
Hiding/showing the action bar is part of the issue but there is also the coloring bug. Jon, please verify the behavior using the originally attached project as well. Actually, we have a customer project in the release phase that have an inconsistent action bar appearance across the various pages due to this bug. It is very embarrassing and, unfortunately, we cannot provide any workaround.
Comment 5 Rui Marinho 2015-07-10 11:13:30 UTC
Hi,on android hiding the actionbar specially with a MasterDetailpage it's not recommended, you can try on your Android project to effective hide the NavigationBar using this XF api:
	
Xamarin.Forms.Forms.SetTitleBarVisibility (Xamarin.Forms.AndroidTitleBarVisibility.Never);

Can you please take a look if it helps at where you try to achieve?! 

We are investigating the color issue. 

Thanks.
Comment 6 Jason Smith [MSFT] 2015-07-15 15:05:16 UTC
Marking as enhancement for investigation about other modes for handling the action bar.
Comment 7 Tibor Ebner 2015-08-26 05:29:41 UTC
I'm glad to see that the problems look to be resolved now on Android 4.4.4, however, Lollipop still reproduces the issue. Please keep up the progress since this is an important feature for us. Our customer has already made remarks about it.
Comment 8 adrianknight89 2016-01-23 07:04:06 UTC
Created attachment 14693 [details]
Color change bug with MasterDetailPage
Comment 9 adrianknight89 2016-01-23 07:04:20 UTC
I have a similar coloring issue. It's very annoying, and unfortunately I need to move lots of code around to try to come up with a workaround. Please see attached zip file (App8).

First of all, NavigationPage.SetHasNavigationBar(this, false); does not work for hiding the action bar. Unfortunately, ActionBar.Hide() in MainActivity.cs doesn't work either, so I ended up resorting to global::Xamarin.Forms.Forms.SetTitleBarVisibility(Xamarin.Forms.AndroidTitleBarVisibility.Never);

ActionBar is hidden on startup. Page1 and Page2 display it. Each page has a different bar color. Color changes will work fine as long as you never make it back to the Home page. Home will hide the action bar. When you display it again, action bar color is set to blue. :(

Another problem is my production Home page has lots of code and navigating back to it to hide the action bar will result in an animation that's not smooth. iOS seems to handle this better. 

On iOS, color changes are not instant. For example, if you move from Page1 to Page2, Page2 will temporarily display Page1's color until the color changes. :(

Would really like to see this bug resolved as it's been hanging around for months.
Comment 10 Samantha Houts [MSFT] 2017-03-16 01:13:38 UTC
https://github.com/xamarin/Xamarin.Forms/pull/753
Comment 11 Rui Marinho 2017-04-11 09:49:52 UTC
Should be fixed on 2.3.5-pre1
Comment 12 Saurabh Paunikar 2017-07-04 11:00:06 UTC
Observed that issue is present on Xamarin.Forms version=2.3.5.256-pre6.For Page2 the navigation bar is still present when it is launch for first time.


ScreenCast: https://www.screencast.com/t/wRsBC5Qc
Comment 13 Jimmy [MSFT] 2017-07-11 22:26:42 UTC
I can confirm that the navigation bar is still present on the first Detail page with Forms 2.3.5.-pre6. I think this happens only when using a MasterDetailPage because this check[1] will return 'true' for the first page.

[1] https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.Android/Platform.cs#L912

Note You need to log in before you can comment on or make changes to this bug.