-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] [Android] Shell.TitleView incorrect positioning of content #3559
Comments
I have the same issue. Any content placed in the Shell.TitleView is either not showing or showing to the right and bottom. Setting a margin causes same results. Also in most cases on the Windows platform nothing shows even when it does show on Androiid. Seems like there is some positioning issue perhaps that makes the content offset enough that it is not visible. |
Verified Repro with Android 11. Repro project |
I don't think this is a new issue The TitlleView unfortunately doesn't do a great job of centering itself. We have a spec over here in That we can hopefully implement inside .NET MAUI at a later point in time. I've copied the issue to here |
This is definitely a new issue introduced with .NET Maui. Worked fine in Xamarin.Forms, but now I get exactly the same behavior as @LarsBehl describes. Have not found any work around so it is a complete blocker to moving forward. It looks like this is verified so you can reproduce it. Please don't wait until a "new feature" is implemented "at a later point in time." This is a serious bug in .NET Maui. |
I feel like this is an issue as old as time. I remember having it in Xamarin Forms too and eventually just gave up on having a custom title bar. I remember setting negative margins worked back then, even if it was janky, now that hack doesn't seem to work in Maui anymore. Basically, something like this:
Which should absolutely fill the whole navigation row, produces this: With that baffling, ever-present left-hand margin that's haunted me for years and makes using TitleView absolute guesswork at best for creating a clean layout. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
The same situation, this question drives me crazy!!! |
I am getting the same problem in a company project. How is this bug allowed to pass ? I'll end up doing like @myrup suggested, just for 10 missing pixels. EDIT : You'll have to add somewhere in your app : Microsoft.Maui.Handlers.ToolbarHandler.Mapper.AppendToMapping("CustomNavigationView", (handler, view) =>
{
#if ANDROID
handler.PlatformView.ContentInsetStartWithNavigation = 0;
handler.PlatformView.SetContentInsetsAbsolute(0, 0);
#endif
}); And I guess learn more about handlers. |
Hello anyone at Microsoft (other than the bot)? Has this fallen through the cracks? It says above that this was added to the .NET7 milestone, and I'm on .NET7 now (and VS 17.5.1) but still have this issue. |
@SmartmanApps The issue was moved to the backlog so it is curretly not fixed. Hopefully they'll work on this issue for the .NET 8 release of MAUI |
Hello @LarsBehl, Thank you for that information, but can we please have more timely updates? The last previous response from someone at Microsoft here says it was added to the .NET7 milestone (in fact 2 comments say that), and there's no subsequent comments to say that it was moved to the backlog instead. |
Verified this issue with Visual Studio Enterprise 17.6.0 Preview 2.0. Still reproduced with the mentioned project above. |
This is still an issue in .NET 8, is there a suitable answer on how to center text in the titlebar with a flyout page/back button in Android/iOS? |
I can confirm that the issue is easily reproducible in Visual Studio 17.8.4 and .NET 8, similar to the previous reports. |
Can you show us the workaround please? |
I fixed this by adding a 4th phanton grid column to the right of width 16, then everything is centered. At least on the android emulator and my phone, havent tested others. I also bind that column width to match the left side when there in auto navigation there and set it OnSizeAllocated to match. This code grabs the screen width and compares it to the title width. Whatever is leftover has been gobbled up by the left side dead or nav area. So i set the phantom column to be that width.
|
I'm ran into this issue also. |
Just wanted to note that we're also finding it difficult to center content in the navigation title view. For those interested, this issue also existed back in the Xamarin days. |
Issue persists with .NET 8.0.90 |
Description
Adding a Custom
Shell.TitleView
to a page results in incorrect positioning of the content. Adding aShell.TitleView
according to the Xamarin.Forms documentation, the image should be displayed horizontally and vertically centered. Instead, it is positioned too far to the right and bottom. A repro is available hereActual behaviour
Expected behaviour
The added image is a menu icon (same as the one for the navigation, just in black). The image should be vertically and horizontally centered in the titlebar.
Steps to Reproduce
Shell.TitleView
to the newly created pageImage
to theShell.TitleView
and addHorizontalOptions="Center"
VerticalOptions="Center"
MainPage
with aShell
xmlns:local="clr-namespace:MauiApp1"
FlyoutItem
to theShell
withShellContent
ContentTemplate="{DataTemplate local:HomePage}"
Version with bug
Preview 10 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 11/API 30
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: