I work on a Xamarin.Forms.Shell app using the default bottom TabBar
, and I need to know the TabBar
height to adjust some items.
I've found a way to get the StatusBar
height on both platforms there, but I didn't found a solution for the TabBar
.
Is it possible? I only found requests about changing the TabBar height on Stack...
Answers
You can create an custom renderer for your shell.
In Android,you cannot get the height at the beginning, when you switch the tab, you can get the height value:
In the iOS, you can get the height like following code.
Hi @LeonLu
As I need to get this information on the HomePage, this solution wouldn't help me
In add, I lose the styles specified in
Shell.xaml
when I use the renderers.If you cannot accept way in android, you can set the height that you want, if you want to adjust your view.
I don't want to change the TabBar height, but I need to know the TabBar height to set limit of a scrollable item.
You can get the height in the
OnCreate()
method directly.@LeonLu
This sounds good for Android. For iOS I need to use the renderer?
In the IOS, you do not need to use custom renderer to achieve it.
The height of UITabbar on iOS is a fixed value . On iPhone 8 and before is 49 and iPhone X and after(full-screen) will have an extra safeArea bottom height . So if you just want to get it (don't need to set the height) , you could get it directly by using DependencyService like following.
You can see Lucas's reply.
https://stackoverflow.com/questions/64892392/xamarin-forms-shell-how-to-get-the-bottom-tabbar-height
@Pacodoso Are there any update for this issue, please reply is helpful, please click the
Yes
tab under the helpful answer.