android - 在 xamarin 表单的标签页(Android)中插入图标

标签 android xaml xamarin xamarin.forms xamarin.android

我是 StackOverflow 社区的新手!
我需要帮助解决 Xamarin Forms 中 android 的一个问题。准确地说……我试着和一些 friend 一起构建我们的第一个应用程序。我们选择(在我们大学教授的帮助下)Xamarin 来使用 Xamarin Forms 为两个系统进行 Android 和 iOS 的跨平台开发。我创建了应用程序的界面部分,现在我被困在一座有大墙的堡垒里。当我尝试添加选项卡式页面功能栏的图标时,应用程序崩溃(Android)但在 iOS 中,问题没有出现......

我会尝试一些解决方案...例如:

-Render in the NameApp.Droid 只为 android 部分添加不同的渲染器但没有结果... - 尝试另一种方法直接在.xaml文件中插入图标​​但没有结果...... -尝试按照另一种方式修改“主题”部分的.axam文件 但没有结果...

我只想在“主项目”中按时整合所有的东西。我现在不想触摸“nameProject.Droid”或“nameProject.iOS”部分,但尝试同时拍摄两者(Andriod 和 iOS)。我在 Android (è.é) 中发现了一个不同的错误,但为此,我快要疯了...... 但是我需要修改“.Droid”没问题我接受挑战!


这是我渴望创造的结果。 "https://storage.googleapis.com/material-design/publish/material_v_12/assets/0B6Okdz75tqQsbHJuWi04N0ZIc0E/components-tabs-usage-mobile7.png "

这是我在标签页中添加图标的方式。假设我将所有内容添加到“.Droid”和“.iOS”中的“资源”中:

        var MainPageTabbed = new MPageTabbed();

        var Profile = new Profile();

        var ListChat = new ListChat();

        if (Device.RuntimePlatform == Device.Android)
        {
            MainPageTabbed.Icon = "ldpi.png";
            Profile.Icon = "ldpi2.png";
            Chat.Icon = "ldpi1.png";

        }

        if (Device.RuntimePlatform == Device.iOS)
        {
            MainPageTabbed.Icon = "ldpi.png";
            Profile.Icon = "ldpi2.png";
            ListChat.Icon = "ldpi1.png";

        }
        NavigationPage.SetHasNavigationBar(this, false); 

        Children.Add(MainPageTabbed);
        Children.Add(Profile);
        Children.Add(ListChat);

有人可以帮我找到解决方案吗?

最佳答案

这里有一个如何在 xamarin 表单中使用 TabbedPage 的示例:

https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/navigation/tabbed-page/

... Xamarin.forms 将 Android 选项卡式页面呈现为与 TabPagerStrib 结合的 viewpager,它看起来像上面链接中的示例。

您可能会阅读有关 Android 的 BottomNavigationBar,或者查看此链接以获取带有图像的 TabPagerStrip:

https://forums.xamarin.com/discussion/39937/adding-icons-to-a-pagertabstrip-instead-of-text

关于android - 在 xamarin 表单的标签页(Android)中插入图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47795048/

相关文章:

xamarin - NavigationPage.SetTitleIcon - 适用于 iOS,但不适用于 Android

android - Xamarin android应用程序在使用BroadcastReceiver引导时崩溃但可以启动吗?

android - 在 Android Webview 中播放视频

c# - 命名空间中不存在自定义控件?

c# - 将 MahApps.Metro 主题和重音应用于其他控件或矩形

c# - Realm .NET - 如何复制/分离对象

java - Firebase 错误 - 无法在 Android Studio 中计算属性 'extraGeneratedResDir' 的值

java - 使用 SimpleAdapter 的 ListView 上没有项目

安卓微调器(下拉): How to know when its clicked (Expanded) and when an item is chosen?

mysql - 在 Xampp 中访问 MySql 数据库