Xamarin Forms Shell TitleView 不居中图像 [英] Xamarin Forms Shell TitleView does not center image

查看:16
本文介绍了Xamarin Forms Shell TitleView 不居中图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它使用 Xamarin.Forms 中的新 Shell.我将以下代码添加到我的一个页面中,以尝试使用 TitleView 区域以居中显示我的应用程序标题图像.(仅供参考 - 我已经为两个对齐选项尝试了 Center,但没有任何区别.)

<图片来源="UCIApp.png"Horizo​​ntalOptions="FillAndExpand"VerticalOptions="FillAndExpand"/></Shell.TitleView>

这样做后我得到的是标题栏中的图像,但在空间中居中,不包括左侧的汉堡按钮,如下所示:

我更喜欢的是它居中,不管汉堡菜单占据的空间看起来像这样:

有什么建议吗?

还 - 将图像放入 TitleView 会导致其缩小.有什么办法可以避免吗?

解决方案

我觉得是 Shell Title View 的设计问题,可以提交GitHub 中的功能请求

可以看到Title View的内容,并且图标已经在Title View居中.由于现有的菜单图标,Title View的权重不等于Navigation Bar.

<块引用>

将图像放入 TitleView 会导致其缩小

参考上面的效果,可以看到图标的大小适应了Title View的显示,并且可以看到Title View的大小,所以你的图标不太可能超出Title View的显示范围.

I have an app that uses the new Shell in Xamarin.Forms. I added the following code to one of my pages in an attempt to use the TitleView area to display my app header image centered. (FYI - I have tried Center for both of the alignment options and it made no difference.)

<Shell.TitleView>
    <Image Source="UCIApp.png"
           HorizontalOptions="FillAndExpand"
           VerticalOptions="FillAndExpand" />
</Shell.TitleView>

What I get after doing this is the image in the title bar but centered in the space the excludes the hamburger button on the left as shown below:

What I would prefer is it centered regardless of the space the hamburger menu takes up looking something like this:

Any suggestions?

ALSO - Putting the image in the TitleView is causing it to be shrunk down. Is there any way to avoid that?

解决方案

I think that's the designed problem about Shell Title View ,you can submit it as a feature request in GitHub here .

What I would prefer is it centered regardless of the space the hamburger menu takes up looking something like this: ... Any suggestions?

The title view already been placed center in Title View . However , it looks like not center in the whole Navigation Bar . Have a look at follow code and effect .

<Shell.TitleView>
    <StackLayout HorizontalOptions="CenterAndExpand"
                 VerticalOptions="CenterAndExpand"
                 BackgroundColor="Accent">
        <Image Source="xamarin_logo.png"
               HorizontalOptions="Center"
               VerticalOptions="Center" />
    </StackLayout>
</Shell.TitleView>

The effect :

You can see that the content of Title View , And the icon already been center in Title View .Because of existing meun icon , the weight of Title View is not equal with Navigation Bar .

Putting the image in the TitleView is causing it to be shrunk down

Refer to above effect , you can see that The size of the icon is adapted to the Title View display, and you can see the size of the Title View, so your icon is unlikely to exceed the display range of the Title View.

这篇关于Xamarin Forms Shell TitleView 不居中图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆