Xamarin.forms Xamarin表单选项卡页面图标很小

Xamarin.forms Xamarin表单选项卡页面图标很小,xamarin.forms,tabbedpage,Xamarin.forms,Tabbedpage,使用带有五个选项卡的选项卡页面,虽然只有两个选项卡的问题相同,但我看到渲染的图标非常小,如图所示,使用了一些占位符图形 我尝试了从32x32到512x512的所有像素分辨率的图像,它们都呈现相同的大小。您可能希望有一个选项来设置此选项,但在寻找解决方案时,它似乎总是归结为制作自定义渲染。虽然我没有看到有人抱怨小图标,但一般来说问题更复杂,所以我仍然希望有一个通用的表单解决方案 在屏幕截图(android设备上)中,我使用了一个主细节页面来提供工具栏和左菜单,但当我有一个干净的选项卡页面时,问题是

使用带有五个选项卡的选项卡页面,虽然只有两个选项卡的问题相同,但我看到渲染的图标非常小,如图所示,使用了一些占位符图形

我尝试了从32x32到512x512的所有像素分辨率的图像,它们都呈现相同的大小。您可能希望有一个选项来设置此选项,但在寻找解决方案时,它似乎总是归结为制作自定义渲染。虽然我没有看到有人抱怨小图标,但一般来说问题更复杂,所以我仍然希望有一个通用的表单解决方案

在屏幕截图(android设备上)中,我使用了一个主细节页面来提供工具栏和左菜单,但当我有一个干净的选项卡页面时,问题是一样的

标签页的定义很琐碎,所以我怀疑这里面有什么问题

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:d="http://xamarin.com/schemas/2014/forms/design"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            mc:Ignorable="d"
            xmlns:views="clr-namespace:CloudDash.Views"
            x:Class="CloudDash.Views.TabPage">

    <TabbedPage.Children>
        <views:ThermalingPage IconImageSource="fly.png"/>
        <views:DataPage IconImageSource="fly.png"/>
        <views:FlightPage IconImageSource="fly.png"/>
        <views:RoutePage IconImageSource="fly.png"/>
        <views:AwarenessPage IconImageSource="fly.png"/>
    </TabbedPage.Children>

</TabbedPage>

如果要使图标变大,必须制作自定义渲染器才能实现。 下面是跑步截图

在Android文件夹中。创建自定义渲染器
MyTabbedPageRenderer.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.Content.Res;
using Android.OS;
using Android.Runtime;
using Android.Support.Design.Widget;
using Android.Support.V4.View;
using Android.Views;
using Android.Widget;
using App22.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms.Platform.Android.AppCompat;

[assembly: ExportRenderer(typeof(TabbedPage), typeof(MyTabbedPageRenderer))]
namespace App22.Droid
{
     public class MyTabbedPageRenderer:TabbedPageRenderer
    {
        public MyTabbedPageRenderer(Context context) : base(context)
       {

       }

        protected override void SetTabIcon(TabLayout.Tab tab, FileImageSource icon)
        {
            base.SetTabIcon(tab, icon);
            tab.SetCustomView(Resource.Layout.Custom_tab_layou);

            var imageview = tab.CustomView.FindViewById<ImageView>(Resource.Id.icon);

            imageview.SetBackgroundDrawable(tab.Icon);

        }
    }
}
在IOS中,您可以参考以下线程:

您还可以在github页面的xamarin部分提出功能请求,PG将看到它


在这种情况下,建议使用
Sharpnado.Presentation.Forms
nuget,您可以随意自定义选项卡:


此问题是否有更新?如果回答是有帮助的,请不要忘记接受这个答案,它将帮助其他有类似问题的人。我确实接受了前一段时间的答案,但把我的评论放在了错误的帖子下面。现在移到这里,上面写着:谢谢。虽然我不喜欢表单中这么多内容的解决方案是“制作一个每个平台的自定义渲染器”,这有点违背了这个目的,但它似乎确实符合解决方案的要求,并且您制作了一个非常简单的示例,确实有效,因此感谢您花时间。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="61dp">
     <ImageView
        android:id="@+id/icon"
        android:layout_width="38dp"
        android:layout_height="38dp"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="4dp"
        android:layout_marginBottom="4dp" />

</LinearLayout>