I have a problem with my Images. I have added some Images to my solution, for the Flyoutitems.
The Images are shown in th Flyout but not in the tabbar in the bottom.
AppShell.xaml
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
<ShellContent Title="News" Icon="tab_feed.png" Route="NewsPage" ContentTemplate="{DataTemplate local:NewsPage}" />
<ShellContent Title="Über den Verein" Icon="tab_team.png" Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
<ShellContent Title="Termine" Icon="tab_calendar.png" Route="TerminPage" ContentTemplate="{DataTemplate local:TerminPage}" />
</FlyoutItem>
Icon="tab_team.png" and Icon="tab_calendar.png" is shown in the Flyout not in the tabbar in the bottom.
I have checked the properties (filelocation, size, build action) of the Images themself, and they are the same as for the Icon="tab_feed.png", which is working fine.
Do you have any hint, what can be wrong with the images.
The icons of the Toolbar may be tinted in Shell. Plase use a monochrome png with transparent background (such as the tab_feed.png) to display the icon. Try to make the image transparent and test again.
Similar issue: https://forums.xamarin.com/discussion/185681/xamarin-forms-tabbedpage-iconimagesource-not-showing-in-ios
Related
I have a floating menu and there are 3 pages in it, but when I navigate to those pages it shows an animation as if the page is coming from the inside out. Only happens with the hamburger menu, with the TabBar that does not happen.
<FlyoutItem Title="Home" Route="HomePage">
<Tab>
<ShellContent ContentTemplate="{DataTemplate home:HomePage}" Style="{StaticResource HomePageShell}" />
</Tab>
<FlyoutItem.Icon>
<FontImageSource
FontFamily="FontAwesome"
Glyph="{x:Static fontello:FontAwesomeIcon.Home}"
Color="Black" />
</FlyoutItem.Icon>
</FlyoutItem>
<FlyoutItem Title="Perfil" Route="PerfilPage">
<Tab>
<ShellContent ContentTemplate="{DataTemplate perfil:PerfilPage}" Style="{StaticResource PerfilPageShell}" />
</Tab>
<FlyoutItem.Icon>
<FontImageSource
FontFamily="FontAwesome"
Glyph="{x:Static fontello:FontAwesomeIcon.UserCircleO}"
Color="Black" />
</FlyoutItem.Icon>
</FlyoutItem>
<FlyoutItem Title="Atención al cliente" Route="SoportePage">
<Tab>
<ShellContent ContentTemplate="{DataTemplate soporte:SoportePage}" Style="{StaticResource SoportePageShell}" />
</Tab>
<FlyoutItem.Icon>
<FontImageSource
FontFamily="Gadgets"
Glyph="{x:Static metroStudio:GadgetsIcon.HeadphoneMike}"
Color="Black" />
</FlyoutItem.Icon>
</FlyoutItem>
Is this what you are looking for.
Look here in the Docs.
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/flyoutpage#navigation-behavior
The behavior of the navigation experience between flyout and detail pages is platform dependent:
On iOS, the detail page slides to the right as the flyout page slides
from the left, and the left part of the detail page is still visible.
On Android, the detail and flyout pages are overlaid on each other.
On UWP, the flyout page slides from the left over part of the detail
page, provided that the FlyoutLayoutBehavior property is set to
Popover.
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/flyoutpage#control-the-detail-page-layout-behavior
How the FlyoutPage manages the flyout and detail pages depends on whether the application is running on a phone or tablet, the orientation of the device, and the value of the FlyoutLayoutBehavior property. This property determines how the detail page will be displayed. It's possible values are:
Default – The pages are displayed using the platform default.
Popover – The detail page covers, or partially covers the flyout
page.
Split – The flyout page is displayed on the left and the detail page
is on the right.
SplitOnLandscape – A split screen is used when the device is in
landscape orientation.
SplitOnPortrait – A split screen is used when the device is in
portrait orientation.
Example in xaml for FlyoutLayoutBehavior
<FlyoutPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="FlyoutPageNavigation.MainPage"
FlyoutLayoutBehavior="Popover">
...
</FlyoutPage>
I'm using "Sharpnado Tabs" and having problem in firing tap event in middle "BottomTabItems".
I have 5 bottom tabs as you can see the attached photo and the areas outlined with black is firing tap event and changing the views accordingly. However, the areas marked with white, is not doing anything.
EDIT
The 5 tabs are spread evenly across the bottom panel. I have set the middle tabs' background to red to see the area they cover and where the touch is working. Setting InputTransparent="true" removes the touch event from the whole area of the tab.
<sho:ViewSwitcher x:Name="Switcher"
Grid.Row="0"
Grid.RowSpan="3"
Animate="False"
SelectedIndex="{Binding SelectedViewModelIndex}">
<sho:LazyView x:TypeArguments="pages:ProfilePage" BindingContext="{Binding ProfilePageViewModel}" />
</sho:ViewSwitcher>
<Image Source="navigationbackground.png" Grid.Row="3" TranslationY="5" />
<sho:TabHostView x:Name="TabHostLogo"
Grid.Row="3"
WidthRequest="200"
HeightRequest="60"
Margin="0"
Padding="0,20,0,0"
HorizontalOptions="Fill"
VerticalOptions="Start"
BackgroundColor="Transparent"
IsSegmented="False"
Orientation="Horizontal"
TabType="Fixed"
SelectedTabIndexChanged="TabHostLogo_SelectedTabIndexChanged"
SelectedIndex="{Binding Source={x:Reference Switcher}, Path=SelectedIndex, Mode=TwoWay}">
<sho:TabHostView.Tabs>
<sho:BottomTabItem IconImageSource="homeiconselected.png" IconSize="20" />
<sho:BottomTabItem IconImageSource="profileicon.png" IconSize="20"/>
<sho:TabButton x:Name="TabButton"
IsVisible="True"
ButtonBackgroundColor="Transparent"
ButtonCircleSize="40"
CornerRadius="40"
IconImageSource="navigationaddbutton.png"
TapCommand="{Binding ProfileViewCommand}"
Scale="2.5"
Margin="0,0,0,15"
TranslationY="-20" />
<sho:BottomTabItem IconImageSource="chaticon.png" IconSize="20"/>
<sho:BottomTabItem IconImageSource="moreicon.png" IconSize="20"/>
</sho:TabHostView.Tabs>
</sho:TabHostView>
The problem is caused by Scale attribute. Unfortunately, that scales the entire tab area, not just the circle button. At Scale=2, half of each of the surrounding buttons are blocked by an invisible expanded tab rectangle (that surrounds the middle tab button).
As you discovered, at Scale=2.5, more than half of the surrounding tabs are invisibly blocked.
I did not find any way to work around this bug. (Other than not using Scale - but then the button is either too small or not a circle, depending on values you use for ButtonCircleSize and CornerRadius.)
I recommend raising this as an issue at github Sharpnado.Tabs issue.
If you do, include a link in that issue to this SO Q&A. And add a link to bottom of your question to that issue - so people can track progress.
So i've created a button and used the to have an image inside the button.
The image i'm providing has a transparent background but when I add it in as a graphic, the program adds a border around it as shown. The book is the iamge i'm providing.
Here's the source code on how i'm adding an image to a button in JavaFXML.
Firstly I defined the id
<fx:define>
<Image fx:id="ReadIcon" url="#Resources/MainIcons/ReadIcon.png" />
</fx:define>
Then I actually add it to the button.
<Button layoutX="363.0" layoutY="583.0" mnemonicParsing="false" onAction="#handleReadHemingwayButtonAction">
<graphic>
<ImageView image="$ReadIcon" />
</graphic>
</Button>
Just not sure how I can remove this border from the image.
Warm Regards
I define a icon in Toolbaritems it show very good in Android on right but in iOS it show icon in ther Center of ther Navigation bar.
How I can put Icon on left same at Android.
Sorry for my poor English.
<ContentPage.ToolbarItems>
<ToolbarItem Text="Back" Order="Primary" IconImageSource="icon_delete_400.png" Clicked="OnBack" />
</ContentPage.ToolbarItems>
Android Show Right (Nice)
enter image description here
iOS show Center (Not good)
enter image description here
Github (Sample Source): https://github.com/westermost/Study-Xamarin
After running your project, I find the cause of your problem is the size of your image is too big(160*160) and it takes half area of the navigationBar, so it looks like stay in the center in your screenshot.
If you give a proper size of the image, it will show at the right side as your expected. I resize the image to 40* 40 and it works well.
Put toolbar item like this
<ContentPage.ToolbarItems>
<ToolbarItem Name="iconexample" Icon="icon_delete_400.png" Priority="0" Order="Primary" Clicked="OnBack" />
</ContentPage.ToolbarItems>
In ios place the image at /mipmap/icon_delete_400.png
In Android place the image at /mipmap/drawable/icon.png
I noticed that if I include an Image element in my WPF application, the image comes out blurry on the screen. To test this, I reduced my program to the bare minimum and created a test image. I tried this in an out-of-browser Silverlight application and in a regular WPF application. I targeted .NET 4 and 4.5. See the same result in all cases.
Test Image
3 pixels wide by 3 pixels high. The middle pixel is red. All others pixels are blue. You can also see it at http://imageshack.com/a/img538/5335/GM4B8I.png
XAML
The entire XAML page is shown below. I added an empty Label above the image and to the left of the image to move it away from the edge of the window.
<Page x:Class="Demo.Home"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="486" d:DesignWidth="864"
Title="Demo">
<StackPanel Background="white" Orientation="Vertical">
<Label FontSize="10" Content=" "/>
<StackPanel Orientation="Horizontal">
<Label FontSize="10" Content=" "/>
<Image Source="/Demo;component/test.png
HorizontalAlignment="Left" VerticalAlignment="Top"
Stretch="None" />
</StackPanel>
</StackPanel>
RESULT:
The 3x3 image is blurred into a 4x4 image. Instead of original blue and red pixels, the pixels are different shades of purple. http://imageshack.com/a/img661/3707/TFdtnF.png
What is causing the blurring? How can I avoid it?
Try adding
RenderOptions.BitmapScalingMode="HighQuality"
to the image.
The blurring results from WPF using sub-pixel precision to calculate position for the Image. The three-pixel image ends up being rendered at non-integer pixel positions, so WPF spreads it over 4 device pixels.
Attempting to fix this using SnapsToDevicePixels did not work. WPF ignores SnapsToDevicePixels for images.
Here is a solution that works http://blogs.msdn.com/b/dwayneneed/archive/2007/10/05/blurry-bitmaps.aspx