How do I use icons e.g. Material Icons instead of PNG iamges in my tabs in a Xamarin Forms app with Shell?
The following is how I defined tabs for home screen in my Xamarin Forms app:
<FlyoutItem Title="Home">
<FlyoutItem.Icon>
<FontImageSource
FontFamily="MISHRP"
Glyph="{StaticResource HomeIcon}"
Color="White" />
</FlyoutItem.Icon>
<Tab Title="Dashboard" Icon="icon_dashboard.png">
<ShellContent Route="Dashboard" ContentTemplate="{DataTemplate views:Dashboard}" />
</Tab>
<Tab Title="My Feed" Icon="{StaticResource Feed}">
<ShellContent Route="MyFeed" ContentTemplate="{DataTemplate views:MyFeed}"/>
</Tab>
</FlyoutItem>
As you can see in above code, in the first tab item (Dashboard), I use a PNG image and that displays fine in my app.
In the second TAB item (My Feed), I tried using an icon I defined in my App.xaml page but that doesn't show at all.
How do I use icons in tabs in a Shell Xamarin Forms app?
I think you use something like this , from the MyCoffeeApp
https://github.com/jamesmontemagno/MyCoffeeApp/blob/master/MyCoffeeApp/MyCoffeeApp/AppShell.xaml
<Tab.Icon>
<FontImageSource FontFamily="FAS"
Color="{AppThemeBinding
Dark=White,
Light={StaticResource SystemGray5Dark}}"
Glyph="{StaticResource IconCoffee}"/>
</Tab.Icon>
Related
I am adding iOS support for my already existing Xamarin Forms android app.
The toolbar items, navigational back arrow and the hamburger menu do not show on iOS:
While they work perfectly on Android:
The Application.MainPage is set to a Shell:
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="app.MainPage"
FlyoutBackgroundColor="{StaticResource cBackgroundColorDark}"
Shell.TabBarTitleColor="{StaticResource cBackgroundColor}"
Shell.BackgroundColor="{StaticResource cBackgroundColor}">
<Shell.Resources>
<ResourceDictionary>
<vm:FlyoutVM x:Key="vm" x:Name="vm"/>
</ResourceDictionary>
</Shell.Resources>
<Shell.FlyoutHeader>
</Shell.FlyoutHeader>
<ShellContent Title="page1"
IsTabStop="True"
ContentTemplate="{DataTemplate views:Page1Page}"/>
...
<Shell.FlyoutContent>
</Shell.FlyoutContent>
<Shell.FlyoutFooter>
</Shell.FlyoutFooter>
</Shell>
The page with the toolbar items is simply:
<ContentPage>
<ContentPage.ToolbarItems>
<ToolbarItem Text="Example"
IconImageSource="Example.png"
Clicked="ExampleToolbarItem_Clicked"
/>
</ContentPage.ToolbarItems>
</ContentPage>
All navigation (hamburger menu, back button ect) and toolbar items can be tapped on iOS and work as intended - they just are not visible.
I do not understand why this does not work on iOS, any suggestions why this might be the case?
(I cannot find any styling that might be making it act differently. I have also tried displaying a toolbar with just text (no icons) and the problem persists)
I can provide more code if needed.
EDIT
I ended up creating a new Xamarin shell template project and moving everything over. That fixed the issue...
Most likely the image size for ios is incorrect. I use this https://appicon.co/#image-sets to create image set for ios.
I want to build a small chat as we all know from WhatsApp.
Currently I am able to display messages within a ListView.
<template>
<Page>
<ListView separatorColor="transparent" for="item in messages">
<v-template>
<GridLayout>
<TextView
height="auto"
editable="false"
:text="item.message"
/>
</GridLayout>
</v-template>
</ListView>
</Page>
</template>
My next step is to add a TextView with a Button at the end of the page. But here are coming my problems:
Which Layout component should I choose to position a TextView at the bottom of the page.
If I tab into my editable TextView the virtual keyboard overlaps my current page. Instead it should resize the whole page. How can I do this?
This is my current playground project: https://play.nativescript.org/?template=play-vue&id=F8lXkO
EDIT:
I found a way which works on Android using DockLayout:
https://play.nativescript.org/?template=play-vue&id=F8lXkO&v=3
Unfortunately this works only in the playground. Using the latest nativescript version on android is not working. If I tab on the TextView the layout breaks => https://github.com/sowinski/nativescript-vue-chat
Use GridLayout for the entire view. You can use this as a guide - https://github.com/Especializa/nativescript-whatsapp-template
Use this to better understand Nativescript layouts - https://www.nslayouts.com/
I am very new to Xamarin. I need to add a image button that display Facebook icon on my Xamarin app and when the user clicks on that icon, I need to be redirected to http://www.facebook.com. How can I accomplish this. Here is what I have so far
<StackLayout Padding="50">
<Image Source="facebook.png" HeightRequest="80" WidthRequest="80" >
<Button Text="Mission" Clicked="Mission_Clicked"></Button>
<Button Text="Continue" Clicked="Continue_Clicked"></Button>
</StackLayout>
On the click of Facebook, I just want the Facebook page to be displayed on the phones.
Any help will be appreciated.
Button already has an Image property
<Button Clicked="FacebookClicked" Image="facebook.png" HeightRequest="80" WidthRequest="80" />
UPDATE Xamarin.Forms 3.4.0
ImageButton:
The ImageButton view combines the Button view and Image view to create a button whose content is an image.
<ImageButton Source="xamagon.png"
BackgroundColor="Transparent"
WidthRequest="300"
HeightRequest="300"
FlexLayout.AlignSelf="Center"
FlexLayout.Grow="1"
Clicked="ImageButton_Clicked"
Aspect="AspectFit">
</ImageButton>
Try to place an image instead of button.
You can make use of Tap Gesture Gesture Recognizer to take click events.
Try something like this :
I have a ToolBarItem in my xaml, this works perfectly on my android but not on iOS. Is there a way to achieve this on both platforms? Also, my app on iOS breaks when i include "Icon=""ic_action_more_vert.png""
My xaml:
<ContentPage.ToolbarItems>
<ToolbarItem Text="About"
Icon="ic_action_more_vert.png"
Priority="0"
Order="Secondary"
Clicked="ToolbarItem_Clicked"/>
<ToolbarItem Text="Settings"
Icon="ic_action_more_vert.png"
Priority="0"
Order="Secondary"
Clicked="ToolbarItem_Clicked_1"/>
</ContentPage.ToolbarItems>
Try to change the priority (1 or 0) and order (Primary or Secondary) of your two ToolbarItems.
Is it possible to configure the icons and splash screens in the config.xml file before creating the windows app's platform folder? If so, how?
I've looked through the documentation on the phonegap site, but don't see a way to do so.
Thanks!
In config.xml, to change icon properties:
If Windows Phone8,
<platform name="wp8">
<icon src="res/wp/ApplicationIcon.png" width="99" height="99" />
<!-- tile image -->
<icon src="res/wp/Background.png" width="159" height="159" />
</platform>
If Windows8,
<platform name="windows8">
<icon src="res/windows8/logo.png" width="150" height="150" />
<icon src="res/windows8/smalllogo.png" width="30" height="30" />
<icon src="res/windows8/storelogo.png" width="50" height="50" />
</platform>
Windows Phone specifies a single splash screen image:
windows-phone/screen-portrait.jpg
Please refer this documentation.