【发布时间】:2019-05-15 18:02:32
【问题描述】:
我根本无法让 Iconize 工作。我根据这个线程(以及其他地方)中的代码创建了一个小型测试项目:
How to change icon color in Xamarin.Forms xaml page?
在 App.xaml.cs 中:
public App()
{
InitializeComponent();
Plugin.Iconize.Iconize.With(new Plugin.Iconize.Fonts.MaterialDesignIconsModule());
MainPage = new MainPage();
}
在 MainActivity.cs 中:
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
Plugin.Iconize.Iconize.Init(Resource.Id.toolbar, Resource.Id.sliding_tabs);
LoadApplication(new App());
}
和 MainPage.xaml:
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:IconizeTest"
xmlns:iconize="clr-namespace:Plugin.Iconize;assembly=Plugin.Iconize"
x:Class="IconizeTest.MainPage">
<StackLayout>
<StackLayout Orientation="Horizontal">
<iconize:IconImage HeightRequest="20" Icon="mdi-bus-double-decker" IconColor="Blue" WidthRequest="20" />
<iconize:IconImage HeightRequest="20" Icon="mdi-bus-double-decker" BackgroundColor="Blue" IconColor="Yellow" WidthRequest="20" IconSize="10" />
<iconize:IconButton FontSize="20" Text="mdi-bus-double-decker" TextColor="Red" WidthRequest="48" />
<iconize:IconLabel FontSize="20" Text="mdi-bus-double-decker" TextColor="Green" VerticalTextAlignment="Center" />
<Label Text="mdi-bus-double-decker" VerticalTextAlignment="Center" />
</StackLayout>
</StackLayout>
</ContentPage>
这是输出在模拟器中的样子的图片(在我的测试设备上看起来一样...):
我喜欢使用 iconize 的想法,它会极大地减少我花在使用图标上的时间。我只是无法让它工作。谁能告诉我我做错了什么?
谢谢! -凯伦
【问题讨论】:
-
你没有收到任何错误吗?
-
@BrunoCaceiro 不。只是重新运行并检查。 “应用程序输出”窗口中没有错误消息。
标签: c# android xamarin.forms